Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
The #1 reason QlikView customers adopt Qlik Sense is a desire for a modern BI experience. Read More
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator III
Creator III

How to Give Rank within a Group

Hi,

I want to give a rank according to Sales but not on overall but within a groups. for e.g. I want a rank within a group for sales in Traditional, Ulip and Saving.

I have tried with a below given logic but by this logic I am getting a rank overall where as my requirement is within a Group..

A:

LOAD Product,

     Sub_Product,

     Sale

FROM

(ooxml, embedded labels, table is Sheet1);

NoConcatenate

B:

LOAD *,

AutoNumber(Sale) as Rank

Resident A Order by Sale desc;

DROP Table A;

EXIT Script

Thanks in advance.

1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Re: How to Give Rank within a Group

your script looks ok. Only change you need is below

AutoNumber(Sale,Product) as Rank

View solution in original post

6 Replies
Highlighted
Creator III
Creator III

Re: How to Give Rank within a Group

HI,

PFA.

$@

Highlighted
Master III
Master III

Re: How to Give Rank within a Group

You can try this at front end, I don't have licensed version so cannot view qvw, below image can help, Product/SubProduct are chosen as dimension in straight table -

Capture.JPG

Highlighted
MVP
MVP

Re: How to Give Rank within a Group

your script looks ok. Only change you need is below

AutoNumber(Sale,Product) as Rank

View solution in original post

Highlighted
Creator III
Creator III

Re: How to Give Rank within a Group

Thanks Kush working fine..Thanks Sam and Digvijay Too.

Highlighted
Partner
Partner

Re: How to Give Rank within a Group

This approach gives the correct results, but is incredibly slow for anything but the smallest data volume. I wrote this up here: https://www.michaelsteedle.com/2019/04/ranking-within-group-quickly-in-qlik.html

TL;DR This is >99% faster: 

If(Product = Previous(Product), Peek(Rank) + 1, 1) as Rank

 

Highlighted
Contributor
Contributor

Re: How to Give Rank within a Group

Thanks Mike,

Great solution. Took a little while to find this, so a 'like' might help future searchers.

Nice work & website too.

Thanks, nick