Model Lookup Function and Aggregate Models

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have two models based on a customer billing object.  They are both aggregate models.  The first is designed to aggregate all open billings for each customer.  The second is designed to aggregate all open billings so that we can view total open billings for our company.  I would like to model lookup the value displayed in the second object into each line of the first aggregate model, but am having trouble doing so. Example:

Aggregate 1:
                     Open Billings (each line will possible contain multiple billing)
Customer 1 - $30
Customer 2 - $60
Customer 3 - $40

Aggregate 2 - 

Total Open Billings: $130

I would like to get the $130 value place on each line of aggregate 1.  Thanks for the help.
Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Christine Jessen

Christine Jessen

  • 670 Points 500 badge 2x thumb
Danny -
Thanks for your question.  I assume your second aggregate model only has one row?  In that case, you should be able to do a model lookup like this on Aggregate Model 1:
MODEL_LOOKUP("AggregateModel2Name","totalOpenBilling","Id","1")
Skuid automatically adds Id's for reference to the aggregate model rows, so to ensure that the Id of the one row in Aggregate Model 2 is equal to "1", move that model to the top in your composer so it loads first.

In addition, remember to replace the totalOpenBilling with the actual alias name generated on Aggregate Model 2 for the total amount.

Hope this helps!
Christine
Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb
Thanks, Christine.  
Yes, the second aggregate model only has 1 row.
With your solution I am now pulling a number, but it is the incorrect number.  The number is larger than the number shown on Aggregate 2.  Any ideas? I checked the condition on both models to ensure they were the same, and they both feed from the same object.
Photo of Christine Jessen

Christine Jessen

  • 670 Points 500 badge 2x thumb
Can you post an image of your model lookup function and your aggregate model setup?
Photo of Danny Hartley

Danny Hartley

  • 434 Points 250 badge 2x thumb
Aggregate 1:

Aggregate 1 UI field:
Model Lookup in Aggregate 1 UI field formula:

Aggregate 2:

Aggregate 2 Aggregation:
Photo of Christine Jessen

Christine Jessen

  • 670 Points 500 badge 2x thumb
Your setup looks good to me, do you have multi-currency enabled in your org? I know that when you aggregate a currency field, the result is in the default orgs currency. If this isn't the issue, can you grant Skuid login access so we can take a look at the page?