# App Development

Announcements
Action-Packed Learning Awaits! QlikWorld 2023. April 17 - 20 in Las Vegas: REGISTER NOW
cancel
Showing results for
Did you mean:
Contributor III

## Ranking Year and Quarter for 2 Different Dimensions

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:

• Company 1: 2019 Q4
• Company 2: 2019 Q3
• Company 3: 2019 Q2

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!

Labels (3)

• ### Rank

1 Solution

Accepted Solutions
Partner - Champion III

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

4 Replies
Partner - Champion III

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

Contributor III
Author

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.

Contributor III
Author

Is there anyway to make this a dimension so I could use it on the X axis in a line chart?

Contributor III
Author

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])

Tags
Community Browser