Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Ramu_i
Creator II
Creator II

Find the top 2 values of names

Hi All,

I have a data

Country Revenu
AUS 1000
IND 2000
UK 3000
US 1000
Japan 3000
Irland  1000
Canada 500
Narway 400
Denmark 400
Nedharland 400
Nepal

3000

 

 

Requirement to get two values of country names in KPI 

here 3000, 2000 is the top 1 and top 2 , 

Here displaying the UK(1), Nepal(1), Japan (1), IND(2)

 

Thanks advacne.

Ram 

1 Solution

Accepted Solutions
Javizh
Partner - Contributor III
Partner - Contributor III

Hello.

In order to achieve that, you need to rank your "Revenu" field with the following expression:

  • aggr(NODISTINCT num(Rank(Revenu,1)),Revenu)

Then, you need to concatenate your countries plus their rank and order them by the revenue

  • Concat(Country &' ('&aggr(NODISTINCT Rank(Revenu,1),Revenu)&')',', ',Revenu*-1)

If you only want the first two ranked ones, then use set analisys in the concat function

  • Concat({<Revenu = {"= Rank(Revenu,1) <= 2"}>} Country &' ('&aggr(NODISTINCT Rank(Revenu,1),Revenu)&')',', ',Revenu*-1)

Then display them in an object big enough to show all of them.

Attached is an example.

Hope its helpful.

Best regards.

View solution in original post

2 Replies
Javizh
Partner - Contributor III
Partner - Contributor III

Hello.

In order to achieve that, you need to rank your "Revenu" field with the following expression:

  • aggr(NODISTINCT num(Rank(Revenu,1)),Revenu)

Then, you need to concatenate your countries plus their rank and order them by the revenue

  • Concat(Country &' ('&aggr(NODISTINCT Rank(Revenu,1),Revenu)&')',', ',Revenu*-1)

If you only want the first two ranked ones, then use set analisys in the concat function

  • Concat({<Revenu = {"= Rank(Revenu,1) <= 2"}>} Country &' ('&aggr(NODISTINCT Rank(Revenu,1),Revenu)&')',', ',Revenu*-1)

Then display them in an object big enough to show all of them.

Attached is an example.

Hope its helpful.

Best regards.

Ramu_i
Creator II
Creator II
Author

Hi Javizh,

Thanks.