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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculated dimension using rank and concat

Hello,

This is a follow up to Variable expansion, quotes and equal sign‌.

Here is my data:

LOAD * INLINE [

  location, id

  siteA, 1

  siteB, 2

  siteC, 3

  siteD, 4

];

If I want a dimension that is a list of all locations, I can either define it in the dimension: ='$(=Concat(location, ', '))'

Or I can create a variable SET vTest= =Concat(location, ', ') and the dimension defined as =vTest

Now, I want to limit how many locations I see to the top two. I know that I can use rank to limit my set like this: =if(aggr(rank(min(id)),location)<=2,location) , but I can't seem to find a way to combine this with Concat to use in a calculated dimension

The result I'm looking for is siteC, siteD. (Order is not important)

Also, is there a way to do this using set expression instead of if statement? My real data is very large and I expect performance will be an issue.

Thanks,

Tanya

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Perhaps like this: =Concat({<location={"=rank(min(id))<=2"}>}location, ', ')


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
antoniotiman
Master III
Master III

Hi Tanya,

it could be

Concat({<id={"=Rank(id)<=2"}>} location,'|')

but You can't use in calculated dimension.

Regards,

Antonio

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Perhaps like this: =Concat({<location={"=rank(min(id))<=2"}>}location, ', ')


talk is cheap, supply exceeds demand