I've created a Object schema for licenses, so I can easily track the licenses that a user has assigned and its cost.
I can get the list of the software and the cost with this:
{{#lookupObjects}}
* {{Name}}
* {{Cost}}
{{/}}
I would like to get the sum of the cost of these licenses, somehow the list.sum isn't working for me:
{{lookupObjects.Cost.sum|0}}
Other list smart values like .size are working for me. Can someone help me? Thanks!
Unfortunately the sum function does not appear to work with lookupobjects.
Workaround:
Create a variable, in this variable use a sum field. Set the variable to 0 as start just for safety.
Example:
Variable Name: SumTotal
Attribute Name: Price
{{#=}}{{SumTotal}}{{#lookupObjects}}+{{Price}}{{/}}{{/}}
This will itterate over the price and put a + before each of them.
With
Object 1 with value 10
Object 2 with value 20
Object 3 with value 30
you would get
{{#=}}0+10+20+30{{/}} which should give you total of 60.
Also remember that this will be set as a text value in the variable so use .asNumber if you need to do further calculations or to set it into a numbers field/object.
Another thing to look out for is empty values as that will mess up the calculation so in your query make sure to remove any object that does not contain value in the Price (example) attribute.
Thanks, I was running in circles, but this helped me out!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.