Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
muniyandi
Creator III
Creator III

Using Aggr Function Top N

I need aggr function clarification . i has displayed Top 5 , Bottom 5 in the calculated dimension.it's based on Amount2 Value

Top 5 = if(Aggr(rank(Sum(Amount2))<=5,Name),Name)

Bottom 5 = if(Aggr(rank(-Sum(Amount2))<=5,Name),Name)

Now i have problem on some cases Below mentioned my demo data. Look Name C  Records,

My formula baseon Amount2 . So Name C have high value and getting top. my problem is one condition check Result (Sum(Amount1/Amount2) ) is not equal to zero and null.

Where to apply Sum(Amount1/Amount2) this formula.

Below mentioned my demo data.

NameAmount1Amount2Result
A10020000.05
B-301000-0.03
C0600000
D2000-400-5
E00#DIV/0!
F3500#DIV/0!
G-400200-2
H60120000.005
I350.821242.62056
J0.42120.7630.552031
K1281.5
L0-10000
M-900#DIV/0!
N30230.9930.129874
O6277820.007967
P800-32-25
Q-23-73.285714
R1000#DIV/0!
S429500.044211
T50082700.060459
1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi Mathew,

Try like this

Top 5 = if(Aggr(rank(Sum({<Amount2-={0}, Amount1-={0}>}Amount2))<=5,Name),Name)

Bottom 5 = if(Aggr(rank(-Sum({<Amount2-={0}, Amount1-={0}>} Amount2))<=5,Name),Name)

Or try like this

Top 5 = if(Aggr(rank(Sum(If(Alt(Amount1/Amount2) <> 0, Amount2))<=5,Name),Name)

Bottom 5 = if(Aggr(rank(-Sum(If(Alt(Amount1/Amount2) <> 0, Amount2))<=5,Name),Name)

Regards,

Jagan.

View solution in original post

15 Replies
its_anandrjs

Then Try expression

If( Sum(Amount1/Amount2) = 0, 0, Sum(Amount1/Amount2) )

jagan
Luminary Alumni
Luminary Alumni

Hi Mathew,

Try like this

Top 5 = if(Aggr(rank(Sum({<Amount2-={0}, Amount1-={0}>}Amount2))<=5,Name),Name)

Bottom 5 = if(Aggr(rank(-Sum({<Amount2-={0}, Amount1-={0}>} Amount2))<=5,Name),Name)

Or try like this

Top 5 = if(Aggr(rank(Sum(If(Alt(Amount1/Amount2) <> 0, Amount2))<=5,Name),Name)

Bottom 5 = if(Aggr(rank(-Sum(If(Alt(Amount1/Amount2) <> 0, Amount2))<=5,Name),Name)

Regards,

Jagan.

Not applicable

Hi Mathew,

You can use

Top 5 = if( Amount1/Amount2<>0 and not IsNull(Amount2)  and Aggr(rank(Sum(Amount2))<=5,Name),Name)

Thanks,

Garry

muniyandi
Creator III
Creator III
Author

Hi Jegan,

First Calculate the sum(Amount1/Amount2) is only number and not equal to zero. after calculate the rank.

muniyandi
Creator III
Creator III
Author

Hi Gaurav ,

sum(Amount1/Amount2) <>0 and Not Isnull(sum(Amount1/Amount2) ) function use and again use aggr function . thats my problem.

muniyandi
Creator III
Creator III
Author

Hi Jegan,

your are close to reach result. sum(amount1/Amount2)<>0 and not isnull(sum(amount1/Amount2)) how to use your expression.

Thanks.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Top 5 = if(Aggr(rank(Sum(If(Alt(Amount1/Amount2, 0) <> 0, Amount2))<=5,Name),Name)

Bottom 5 = if(Aggr(rank(-Sum(If(Alt(Amount1/Amount2, 0) <> 0, Amount2))<=5,Name),Name)

Regards,

Jagan.

muniyandi
Creator III
Creator III
Author

Hi Jegan,

top it's fine. I have another dobut on bottom condition calcuation.

Bottom time we have sum of value getting - minus value , again we put front of -minus,

this time ex ( -sum(-500)= +500) how to solve this issues.

we need to write if condition (if (sign(sum(amount2))=-1,sum(amount2),-sum(amount2)) ?

Thanks,

jagan
Luminary Alumni
Luminary Alumni

Hi

sum(amount2) * -1


Regards,

Jagan.