Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the sum of Insight attributes?

Laura López
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 18, 2022

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! 

2 answers

1 accepted

1 vote
Answer accepted
Krister Broman _Advania_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 11, 2024

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. 

 

Rudy Holtkamp
Community Champion
May 10, 2024

Thanks, I was running in circles, but this helped me out!

0 votes
青山 明
Contributor
July 7, 2023

Did this issue get resolved?
I am also facing this issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events