Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikChick
Contributor II
Contributor II

Qlik Sense: Showing only the first value...FirstSorted or Above/Below?

Greetings! 

Looking for some much needed help with a chart in Qlik Sense. Here's what I have:

ClientProducts
111004Basic
111007Complete
111007Essential
111007Basic
114027Complete
114027Complete
114027Essential
114027Basic
114027Basic

 

I would like to display unique values for the client. Basically  I need to know what the highest level of product a  unique client has with us (multiple clients because of multiple locations). Complete being the top, secondary is Essential, then Basic. Here's what the end result would be in my ideal table:

ClientProducts
111004Basic
111007Complete
114027Complete

 

Help would be greatly appreciated...I'm not sure how to use FirstSorted Value in this case, or Above/Below...

Thanks!

Jenny

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

The best way is to create a flag in Script like if Basic then 1, if Essentials then 2, if complete then 3 etc.

Ans then you can write advanced set analysis to get the right data.

The expression in this case will be

Maxstring({<Flag = p({<Flag = {'=Aggr(Max(Flag),Client)'}>})>}Products)

If you dont want to do that you can create a table with client and products as dimension and expression as

Aggr(Max(If(Products = 'Basic',1,If(Products='Essential',2,If(Products='Complete',3)))),Client)

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

The best way is to create a flag in Script like if Basic then 1, if Essentials then 2, if complete then 3 etc.

Ans then you can write advanced set analysis to get the right data.

The expression in this case will be

Maxstring({<Flag = p({<Flag = {'=Aggr(Max(Flag),Client)'}>})>}Products)

If you dont want to do that you can create a table with client and products as dimension and expression as

Aggr(Max(If(Products = 'Basic',1,If(Products='Essential',2,If(Products='Complete',3)))),Client)

 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
QlikChick
Contributor II
Contributor II
Author

Thanks, Kaushik! 

I have altered the script as you mentioned, and now I have this:

ClientProductsRank
111004Basic1
111007Complete3
111007Essential2
111007Basic1
114027Complete3
114027Complete3
114027Essential2
114027Basic1
114027Basic1

 

When I try to add this part below, I get an error:

Maxstring({<Flag = p({<Flag = {'=Aggr(Max(Flag),Client)'}>})>}Products)

I am adding it as a column in my straight table. It tells me the expression is "OK", but I do get an error and it does not work on the visualization.

Thanks for the reply BTW, any further help is greatly appreciated!

 

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

Because your new field name is Rank, your expression should replace the Flag with Rank keyword. so the expression should be

Maxstring({<Rank= p({<Rank= {'=Aggr(Max(Rank),Client)'}>})>}Products)

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!