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

If you need to add the Date information, use an expression:

Campaign Customer Only(Date) Num(Rank(-Only([Years with Company]),4,1))
X101-01-161
X202-01-162
X303-01-163
X404-01-164
X505-01-165
Y106-01-161
Y207-01-162
Y308-01-163
Y409-01-164
Y510-01-165
kushalthakral
Creator III
Creator III
Author

But at the end i want to show this info as below:

sum of all the ranks of that particular campaign

 

CampaignSum of Rank
X15
Y15
swuehl
MVP
MVP

Again:

Campaign =(sqr(Count(DISTINCT Customer))+Count(DISTINCT Customer))/2
X15
Y15
swuehl
MVP
MVP

Or if you insist on the overhead of advanced aggregation and ranking:

Sum(Aggr(Num(Rank(-Only([Years with Company]),4,1)),Campaign,Customer))

Campaign Sum(Aggr(Num(Rank(-Only([Years with Company]),4,1)),Campaign,Customer)) =(sqr(Count(DISTINCT Customer))+Count(DISTINCT Customer))/2
X1515
Y1515
kushalthakral
Creator III
Creator III
Author

Can you please explain the formula what is is doing

swuehl
MVP
MVP

If you have N lines showing the rank from 1 to N, the formula will calculate the sum of these values 1 to N.

=(Sqr(N)+N)/2

That's just maths, not depending on the rank() function.

Count(DISTINCT Customer) is giving the number of these lines (N) per campaign.

kushalthakral
Creator III
Creator III
Author

Thanks Swuehl

for now its working i will revert back if i need some more information on the same

Regards

Kushal Thakral

kushalthakral
Creator III
Creator III
Author

Hi Swuehl

It is not working if we have multiple customer on two different dates

Can you please help in that.

Regards

Kushal Thakral

swuehl
MVP
MVP

Can you post a sample input table and your requested output?

kushalthakral
Creator III
Creator III
Author

Hi

Please look at the below table

    

    

  

Campaign NameCustomerYears with CompanyLead Date=Aggr(Num(Rank(-Only([Years with AIB]),4,1)),[Campaign Name],Customer)
1
A69883867422171
B69883867422381
C6988386742271-
C69883867422721