Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi,
I would like to rank the following 'Annual population' table by year and country.
For instance, there are 10 country categories each year. I would like the ranking to reset each year (please refer to the snip below)
Many thanks in advance.
Martynas
Solved! Go to Solution.
I used the following code and it worked:
One way to rank the 'Annual population' table by year and country, with the ranking resetting each year, is to use the RANKX function in DAX. Here's an example formula that implements this:
```
Rank = RANKX(
FILTER(
'Annual population',
'Annual population'[Country] = EARLIER('Annual population'[Country]) &&
'Annual population'[Year] = EARLIER('Annual population'[Year])
),
'Annual population'[Population],
,
DESC,
Dense
)
```
Hope this helps!
Hi @aaitelkadi ,
Unfortunately, I get an error using this DAX formula regarding the EARLIER function
Any advice?
I used the following code and it worked:
Perfect. I am glad it worked for you.
User | Count |
---|---|
89 | |
82 | |
48 | |
40 | |
35 |