Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
NickMol25
Frequent Visitor

RankX in matrix. Get overall ranking instead of rank per hierarchy category.

Good afternoon. I am working on a measure that shows a Top N and Others category in a matrix. Currenty it shows the top 5 countries per Year based on Sales. 

I now want my matrix to simply show the Top 5 countries with the highest total sales sum independent of year. 

For example.
- In 2021 China, UK, Germany, Denmark, and Netherlands had the most sales. 

- In 2022 China, UK, Germany, Netherlands , and Taiwan had the most sales. 

- Over all years combined, UK, USA, Netherlands, Germany, and France had the highest sales. 

Now I only want to see the countries with the highest sales over all years (including others category) in my matrix. How can I achieve this? I am now using the measure below: 

 

 

Ranking = 
VAR Ranking = 
    RANKX(ALLSELECTED('Country names'[Country Name]),
    [Gigawatt]
        )
VAR isOtherSelected = SELECTEDVALUE('Country names'[Country Name]) ="Others"
VAR Result = if(isOtherSelected,-1,Ranking)

Return 
    Result

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

If you want to disregard time completely in your calculations of ranks, then it's as easy as:

 

[Ranking w/o Time] =
CALCULATE(
    [Ranking],
    REMOVEFILTERS( Dates )
)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

If you want to disregard time completely in your calculations of ranks, then it's as easy as:

 

[Ranking w/o Time] =
CALCULATE(
    [Ranking],
    REMOVEFILTERS( Dates )
)

Thank you very much. Worked perfectly. Will accept this as the solution!

Anonymous
Not applicable

Is it not enough to remove the years from the matrix? Just create another matrix and don't slice by years. 

I'm first trying to get it to work in a matrix because I later on want to use it as a dynamic legend of a stacked bar chart. So unfortunately that is not an option. 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.