Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
andrespa
Specialist
Specialist

Bottom sum

Hi everyone,

I have a little problem that I can't figure out the solution. I have a straight table like shown below:community_Question.jpg

I have check the Max number option to 15 in the table, so the total of the Net Margin column (11.680,779,7) is not what I want to show in the title.

max.PNG

What I want to do is to sum the first 15 values of the Net Margin column and put them into the title of the expression. Currently I have tried all these expressions:

=Bottom(sum({<TypeFact={'Sales'}>} P_Margin_net*$(vCurrencyRate)))  // this one give me the total of all rows in the Net Margin column

=sum(aggr(if(rank(aggr(rangesum(sum({<TypeFact={'Sales'}>} P_Margin_net*$(vCurrencyRate))),Customer_number),4)<=15,

aggr(rangesum(sum({<TypeFact={'Sales'}>} P_Margin_net*$(vCurrencyRate))),Customer_name)),Customer_number))

Hope I was clear enough.

Thanks,

Andrés

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I think just flip the sign of the sum in gysbert's expression to get the last 15 values:

sum({<TypeFact={'Sales'}, Customer_number={"=rank(-sum({<TypeFact={'Sales'}>} P_Margin_net))<=15"}>} P_Margin_net*$(vCurrencyRate))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

7 Replies
MayilVahanan

Hi

Try like this

=Sum(Aggr(If(Rank(sum({<TypeFact={'Sales'}>} P_Margin_net*$(vCurrencyRate)) ) <=15,

          Sum({<TypeFact={'Sales'}>} P_Margin_net*$(vCurrencyRate))

), Customer_number, Customer_name))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
andrespa
Specialist
Specialist
Author

Hi Mayil, sorry it shows me the same result as before. Not what I lookinf for.

Thanks anyway.

MayilVahanan

HI

Can you provide a sample file

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Gysbert_Wassenaar

Try this one:

sum({<TypeFact={'Sales'}, Customer_number={"=rank(sum({<TypeFact={'Sales'}>} P_Margin_net))<=15"}>} P_Margin_net*$(vCurrencyRate))


talk is cheap, supply exceeds demand
andrespa
Specialist
Specialist
Author

Hi Gysbert, that was close. It shows me the first 15 margin values, but what I want is the last 15. In the chart I'm able to do that by sorting descending by numeric value. But on the text object I can't do that. Any ideas of how to achieve that?

Cheers,

Andrés

jonathandienst
Partner - Champion III
Partner - Champion III

I think just flip the sign of the sum in gysbert's expression to get the last 15 values:

sum({<TypeFact={'Sales'}, Customer_number={"=rank(-sum({<TypeFact={'Sales'}>} P_Margin_net))<=15"}>} P_Margin_net*$(vCurrencyRate))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
andrespa
Specialist
Specialist
Author

It worked! Thanks a lot!