Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
kushalthakral
Creator III
Creator III

Rank function with multiple dimensions

Hi All

I have some queries regarding use of rank function

i have data like below

CampaignCustomerYears with CompanyDateRank Header 6

I am calculating Rank using below formula

Aggr(Num(Rank(Total -[Years with Company],4)),Customer,[Campaign],[Years with Company],[Date])

Now i want to use the same in the below table but not getting proper output can any have a solution to this

CampaignRank

Regards

Kushal Thakral

29 Replies
swuehl
MVP
MVP

Maybe

Only(TOTAL<[Campaign Name], Customer> Aggr(Num(Rank(-Only([Years with AIB]),4,1)),[Campaign Name],Customer))

or

=Only(Aggr(NODISTINCT Num(Rank(-Only([Years with AIB]),4,1)),[Campaign Name],Customer))


kushalthakral
Creator III
Creator III
Author

I have tried your solution but it is assigning same rank to all other customers

like

A 1

B 1

C 1

but the result should be like

A 1

B 2

C 3

Thanks

Kushal

swuehl
MVP
MVP

Please post a small sample application.

As far as I understood, A,B,C are campaign names, and you don't want to rank across campaigns.

kushalthakral
Creator III
Creator III
Author

For this example i have taken A, B, C as Employees just to elaborate the output of your solution

swuehl
MVP
MVP

Can't reproduce it here.

Please post a small sample QVW.

kushalthakral
Creator III
Creator III
Author

okk i will post in some time

Saravanan_Desingh

To add to swuehl formula, we can also use the below:

(Count(DISTINCT Customer)/2)*(2*FirstSortedValue(Customer,Customer)+(Count(DISTINCT Customer)-1)*(FirstSortedValue(Customer,Customer,2)-FirstSortedValue(Customer,Customer)))

Here, in your example the sequence is like 1,2,3,4..

But if you have sequence like 1,3,5,7,9,11 the above formula can be used..

kushalthakral
Creator III
Creator III
Author

Hi Swuehl

i am attaching the sample QVW file , have a look on it

Actually i want a Rank column for individual Campaigns based on Years with Company and T

and for a new campaign rank should starts with 1

as of now it is showing a continuous rank

Thanks

Kushal

swuehl
MVP
MVP

Maybe just remove the TOTAL qualifier from the Rank() function

=Aggr(Num(Rank( -([Years with Company]),4)),Campaign,T)

kushalthakral
Creator III
Creator III
Author

Thanks a lot Swuehl

It was a simple thing, i dont know how i missed that

Thanks

Kushal