Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Wahab
Contributor II
Contributor II

Need to Rank starting with specific number in set analysis

Hi all,

I'm trying to rank certain values if greater than 1 will equal 40, but then also rank whatever is less than 1 to start with 30 and go in descending order as the percentage value decreases (30..29..28..etc).  The result I get now is the least percentage value (67.82%) is receiving the 30 and the most (99.13%) is receiving the least.  I just want it flipped if possible.  See example of code below and results.  Thank you to everyone who tries to help with this!

 

If(
(Sum({<%Date={"$(vMTD)"}>}Amt)
/
Count({<%Date={"$(vMTD)"},[PayType.PayType]={'C'},[RO_Detail.hasLabor]={1}>}distinct [%RO]))
/
Only({<%Date={"$(vMTD)"},[PayType.PayType]={'C'}>}BM_GrossRO)
<1.1
and
(Sum({<%Date={"$(vMTD)"}>}Amt)
/
Count({<%Date={"$(vMTD)"},[PayType.PayType]={'C'},[RO_Detail.hasLabor]={1}>}distinct [%RO]))
/
Only({<%Date={"$(vMTD)"},[PayType.PayType]={'C'}>}BM_GrossRO)
>=1,40,

if(
((Sum({<%Date={"$(vMTD)"}>}Amt)
/
Count({<%Date={"$(vMTD)"},[PayType.PayType]={'C'},[RO_Detail.hasLabor]={1}>}distinct [%RO]))
/
Only({<%Date={"$(vMTD)"},[PayType.PayType]={'C'}>}BM_GrossRO))
<1,
31-
Rank(-
((Sum({<%Date={"$(vMTD)"}>}Amt)
/
Count({<%Date={"$(vMTD)"},[PayType.PayType]={'C'},[RO_Detail.hasLabor]={1}>}distinct [%RO]))
/
Only({<%Date={"$(vMTD)"},[PayType.PayType]={'C'}>}BM_GrossRO))
))

 

Wahab_0-1743164807151.png

 

 

Labels (4)
3 Replies
rubenmarin1

Hi, at the end you have:

31-
Rank(-
((Sum({<%Date={"$

If you remove the minus in red (at the start of the Rank expression) you'll get the rank flipped.

Wahab
Contributor II
Contributor II
Author

Thank you for the reply but unfortunately it  starts it at -1.  I have a screenshot below with the result of removing that '-', the red shows what I'm trying to make it look like, if that helps.

Wahab_0-1743170348416.png

 

rubenmarin1

Can you try to set the rank in a different expression to see the value it returns for each of those rows? to confirm that it really returns 32, 33, 34...

In that case you can use a count of the values above 100% to add it to the rank operation like:

31-
Rank(.... )
+ [NumOfValuesAbove100%]