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

RANK

I have data like below

Country , Sales, Growth

A,100,12

B,200,23

C,200,34

 

i my case i need to show only top 2 if i use sales it is showing both B&C  i need to show only C because this case i need to rank on growth

if rank Repeat i need to choose max Growth

 

is it possible

Channa
2 Replies
lorenzoconforti
Specialist II
Specialist II

Not 100% sure what you are looking for but possibly something like this?

=Rank(RangeSum(Sum(Sales), Sum(Growth)))

Rank.png

JordyWegman
Partner - Master
Partner - Master

Hi Channa,

Try this, it will give the right combination. I've added an example (D).

2020-01-02 17_09_13-Qlik Sense Desktop.png

//Example code
Table:
Load * Inline [
Country , Sales, Growth
A,100,12
B,200,23
C,200,34
D,300,34
];

// Get the ones with the highest Growth if the sales are the same.
Left Join (Table)
Load
	Country,
    1 as _indRank
;
Load
	Sales,
    FirstSortedValue(Country,- Growth) as Country,
    Max(Growth) as MaxGrowth
Resident Table
Group by Sales desc
;

// Get all the ranked and rank them ordered by sales
FinalTable:
Load
	*,
    RowNo() as Rank
Resident Table
Where _indRank = 1
Order by Sales desc
;

// Add all the ones that are not ranked
Concatenate(FinalTable)
Load
	*
Resident Table
Where IsNull(_indRank)
Order by Sales
;

Drop table Table;

Jordy

Climber

Work smarter, not harder