Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

HOWTO: Make a top 5 static?

Hi everybody,

I'm trying to make a top 5 idependent of the current selections in a text box but I'm a bit stuck.

How could I alter this expression so that it remains static?

AGGR(IF(RANK(SUM(Contractors.Test_Cost))=1,Contractors.Fullname&': '&num(SUM(Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)&'

'&
AGGR(IF(RANK(SUM(Contractors.Test_Cost))=2,Contractors.Fullname&': '&num(SUM(Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)&'

'&
AGGR(IF(RANK(SUM(Contractors.Test_Cost))=3,Contractors.Fullname&': '&num(SUM(Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)&'

'&
AGGR(IF(RANK(SUM(Contractors.Test_Cost))=4,Contractors.Fullname&': '&num(SUM(Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)&'

'&
AGGR(IF(RANK(SUM(Contractors.Test_Cost))=5,Contractors.Fullname&': '&num(SUM(Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)

I might be doing it the wrong way...

Thanks!

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Try Something like below... Change your field names accordingly.

=CONCAT({1}DISTINCT IF(Aggr(Rank(SUM({1}Sales),4),[Customer Name])<=5,[Customer Name]),' '&CHR(13),

  -AGGR(SUM({1}Sales),[Customer Name]))

View solution in original post

11 Replies
Gysbert_Wassenaar

If by static you mean independent of selections then add {1} in every sum:

AGGR(IF(RANK(SUM({1}Contractors.Test_Cost))=1,Contractors.Fullname&': '&num(SUM({1}Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)&'


talk is cheap, supply exceeds demand
alexandros17
Partner - Champion III
Partner - Champion III

If static means that values donìt change with selection you need to exclude in each sum the fields taht could be used:

SUM({$ <field1=, field2= >} Contractors.Test_Cost) in this way for any selection of field 1 and 2 values don't change

Not applicable
Author

Yes I thought that would be the solution but it's not working. I'm on QV10.

If I select fields such as %Cost_centre or a division this expression is impacted for some reason...

Not applicable
Author

Just tried: 

AGGR(IF(RANK(SUM({$ <%Cost_centre=, Contractors.Division=,Contractors.Fullname= >} Contractors.Test_Cost))=5,Contractors.Fullname&': '&num(SUM({$ <%Cost_centre=, Contractors.Division=,Contractors.Fullname= >}Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)

It returns null when I select a Cost centre...

So does:

 

AGGR

(IF(RANK(SUM({1}Contractors.Test_Cost))=1,Contractors.Fullname&': '&num(SUM({1}Contractors.Test_Cost),'£#,##0.##')),Contractors.Fullname)

MK_QSL
MVP
MVP

Try Something like below... Change your field names accordingly.

=CONCAT({1}DISTINCT IF(Aggr(Rank(SUM({1}Sales),4),[Customer Name])<=5,[Customer Name]),' '&CHR(13),

  -AGGR(SUM({1}Sales),[Customer Name]))

Not applicable
Author

Yep, that worked.

 

=CONCAT({1}DISTINCT IF(AGGR(RANK(SUM({1}Contractors.Test_Cost),4),Contractors.Fullname)<=5,Contractors.Fullname),'
',
-
AGGR(SUM({1}Contractors.Test_Cost),Contractors.Fullname))


Now I need to understand it!

Thanks.

MK_QSL
MVP
MVP

=CONCAT({1}DISTINCT IF(AGGR(RANK(SUM({1}Contractors.Test_Cost),4),Contractors.Fullname)<=5,Contractors.Fullname),'
',
-
AGGR(SUM({1}Contractors.Test_Cost),Contractors.Fullname))


We have FIXED SUM and CONCAT Both...


IF(AGGR(RANK(SUM({1}Contractors.Test_Cost),4),Contractors.Fullname)<=5,Contractors.Fullname)

Will check Rank for First 5


Now We have CONCAT the result of above with separator ' ' 


-AGGR(SUM({1}Contractors.Test_Cost),Contractors.Fullname)

Will Sort the CONCAT order by SUM of Your desired dimension.


Not applicable
Author


The only down side is that I cannot display the Contractor cost with this method.

I wonder if there's a way to do it.

MK_QSL
MVP
MVP

Something Like This?

=CONCAT({1}DISTINCT

     IF(Aggr(Rank(SUM({1}Sales),4),[Customer Name])<=5,

          Aggr([Customer Name]&' '&SUM(Sales),[Customer Name])),' '&CHR(13),

  -AGGR(SUM({1}Sales),[Customer Name]))