Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
emrekaya
Contributor III
Contributor III

Summation of Max values in a column

Hi all,

I have a problem with the summation of max values in a column. As you see below, my table has different master spendings and their subbranches. I want to sum the master spendings, in that case only YA.XXXX codes. I've tried some set analysis solutions but they didn't work. When I tried to use aggr() function, I got some results which were not correct. I could use max function for every one of master spendings but my table has so many rows , so that was impossible. If you help me, I would be glad.

Thanks in advance.

Edit: 

The formula I use is;

sum(aggr(max([Spendings]),Elements))

 

 

 

123.PNG

Labels (2)
1 Solution

Accepted Solutions
emrekaya
Contributor III
Contributor III
Author

In order to achieve that, I generated another field in my script as left(Elements,7) as MasterCode and instead of Elements, I used MasterCode in my "sum(aggr(max([Spendings]),Elements))" formula. 

View solution in original post

5 Replies
emrekaya
Contributor III
Contributor III
Author

In order to achieve that, I generated another field in my script as left(Elements,7) as MasterCode and instead of Elements, I used MasterCode in my "sum(aggr(max([Spendings]),Elements))" formula. 

tresesco
MVP
MVP

Not sure I understand right. Your expression looks in right path. Since that doesn't give right result, you could try :

sum(aggr(NODISTINCT max([Spendings]),Elements))
emrekaya
Contributor III
Contributor III
Author

I tried to use left(Elements,7) in the expression and it didn't work but when I used the same expression in the script and saved as another field, that new field worked pretty well in the expression.

tresesco
MVP
MVP

That is because you can't use expression in aggr() as dimension but only script-generated field.
emrekaya
Contributor III
Contributor III
Author

Thank you, that is really helpful for my possible applications in qliksense.