Discussion board where members can learn more about Qlik Sense App Development and Usage.
Hello,
I am trying to rank the most recent year and quarter for us and our competitors so I can show trends for the most recent four quarters of data, but cannot figure out how to make the ranking reset for each company. For example, this is what my data looks like before ranking:
Company | Company Owner | Year | Quarter | Rank |
Company 1 | My Company | 2019 | 1 | |
Company 1 | My Company | 2019 | 2 | |
Company 1 | My Company | 2019 | 3 | |
Company 1 | My Company | 2019 | 4 | |
Company 2 | Competitor | 2018 | 4 | |
Company 2 | Competitor | 2019 | 1 | |
Company 2 | Competitor | 2019 | 2 | |
Company 2 | Competitor | 2019 | 3 | |
Company 3 | Competitor | 2018 | 3 | |
Company 3 | Competitor | 2018 | 4 | |
Company 3 | Competitor | 2019 | 1 | |
Company 3 | Competitor | 2019 | 2 |
As you can see, the most recent quarters:
I would like the ranking to behave as followed:
Company | Company Owner | Year | Quarter | Rank |
Company 1 | My Company | 2019 | 1 | 4 |
Company 1 | My Company | 2019 | 2 | 3 |
Company 1 | My Company | 2019 | 3 | 2 |
Company 1 | My Company | 2019 | 4 | 1 |
Company 2 | Competitor | 2018 | 4 | 4 |
Company 2 | Competitor | 2019 | 1 | 3 |
Company 2 | Competitor | 2019 | 2 | 2 |
Company 2 | Competitor | 2019 | 3 | 1 |
Company 3 | Competitor | 2018 | 3 | 4 |
Company 3 | Competitor | 2018 | 4 | 3 |
Company 3 | Competitor | 2019 | 1 | 2 |
Company 3 | Competitor | 2019 | 2 | 1 |
This way, the most recent quarter for each company is the highest rank. I have tried aggregation on Year, Quarter, Company, and attempted many other things, but to no avail. Any input would be greatly appreciated!
Here is a way to calculate the rank as you ask for I believe:
The expression is:
Max(TOTAL <Company> Year*4+Quarter) - Max(TOTAL <Year,Quarter> Year*4+Quarter) + 1
Here is a way to calculate the rank as you ask for I believe:
The expression is:
Max(TOTAL <Company> Year*4+Quarter) - Max(TOTAL <Year,Quarter> Year*4+Quarter) + 1
Thank you so much! It works exactly as intended! I have never put values in the <> before, so I honestly have no clue why it is working, but it works.
Is there anyway to make this a dimension so I could use it on the X axis in a line chart?
Figured out a way to, essentially, turn this measure into a dimension in case anyone was curious:
Aggr(Max(TOTAL <Company> Year*4+Quarter) - Max(TOTAL <Year,Quarter> Year*4+Quarter) + 1, [Year], [Quarter], [Company])