I’ve managed to get Ui-only formula fields to work using aggregations within the same model, but am having trouble pulling in a number from a different model.
My goal is to show an an average, by dividing a count from one model by a distinct count from another. I think I should be able to do this with a model_lookup in a Ui-only formula field.
Here’s what I have, please let me know if there’s something I am doing wrong, or if I’m running into the limitations of Skuid/salesforce.
On the Cancellations aggregate model, can you try giving it an aggregate function (e.g. AVG of AvgCancel…). If that doesn’t work, try re-querying the MonthlyActiveClients model when the page loads (you can do this with a tab initial load action for example). Lastly, if that doesn’t work, try wrapping your formula in VALUE(xxxx) functions. It should be VALUE(xxx)/VALUE(MODEL_LOOKUP(xxx)).
I have a suspicion that your UI only field is not actually getting populated. Put that field in a template, or build a table to see if you are actually getting values. I think your model lookup function is returning a string, which is not working in your divide by calculation. You might wrap the model lookup section in a “Value()” Function.
But it still won’t return anything. I’m not sure if I’m using the model_lookup function correctly. I think the first two arguments are correct, but I’m not sure about the last two. Both models are grouping data at the calendar month level.
Here is a little help on the four arguments of the model lookup formula. Arg 1: Model ID of what you are looking up against. Arg 2: Field id of the value that you want to return into your UI only field. (in this case - in an aggregate model, you use the alias fieldname) Arg 3: Field id in the Model from Arg 1 that is used to match against. Note - Arguments 1 - 3 need to be in quotes. Arg 4: Field from the model you are building the UI Only model on that you want to pass over in order to retrieve. This argment is usually in our merge syntax.
So… this is what you are telling skuid to do: Retrieve the count of coaches from the MonthlyActiveClients model when the SnapshotDate month is the same as the EndDate month from the current model.
That makes sense to me. However, it’s perplexing, because I think I’ve set up my model_lookup correctly.
I think the issue must be in the Arg 4, because I don’t see any room for error in the first 3. Can you explain more “This argment is usually in our merge syntax” statement?
cmEndDateC is the grouping on my ‘CancellationsThisYear’ model. It’s a ‘date’ field in salesforce, that I applied the calendar month “Function” to in the grouping of the model.
I’ve attached images of the groupings and the native fields in salesforce.
In my mind, grouping a date field by calendar month should return the same thing as any other date field grouped by calendar month. Am I missing something here? I’ve used a template within a table to display the data and both cm date fields process fine.
This is silly, but I think I found a way to make it work.
Create a new UI-Only field that shows the value of your close date in a number format. Do that for both fields in the models you are connecting via the MODEL_LOOKUP function. Then, when writing the formula, use the Values to connect the two instead of the actual fields.
It works flawlessly. I appreciate the creative solution. Had you run into a similar issue? Wondering if this is an isolated problem with dates and date functions.
Thanks to all three of you for helping solve this problem.