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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ivandgreat
Helper I
Helper I

summarize monthly ranking per category

Hello, i was having some difficulties to get the DAX formula for monthly rank.

i would like to summarize my table that shows only the top rank per each month with respect to region category as shown below table.

anyone could assist me to achieve this. Thanks.

 

MonthRegionCost Rank
​​​​​​​​​​​JanCR2153098  
​​​​​​​​​​​JanER1832120  
​​​​​​​​​​​JanWR1419893  
​​​​​​​​​​FebCR2093887  
​​​​​​​​​​FebER1254795  
​​​​​​​​​​FebWR2932801  
​​​​​​​​​MarCR3843352  
​​​​​​​​​MarER2167873  
​​​​​​​​​MarWR4185748  
​​​​​​​​AprCR5245395  
​​​​​​​​AprER3301028  
​​​​​​​​AprWR7426182  

 

 

The result table, that i could put graph

 

MonthRegionCost Rank
​​​​​​​​​​​JanCR2153098 1
​​​​​​​​​​FebWR2932801 1
​​​​​​​​​MarWR4185748 1
​​​​​​​​AprWR7426182 1
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @ivandgreat ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a measure as below

Rank = 
VAR _selmonth =
    SELECTEDVALUE ( 'Table'[Month] )
RETURN
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month] = _selmonth ),
        CALCULATE ( SUM ( 'Table'[Cost] ) ),
        ,
        DESC,
        DENSE
    )

2. Create a table visual and apply a visual-level filter with the condition (Rank is 1)

vyiruanmsft_0-1696495385474.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @ivandgreat ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a measure as below

Rank = 
VAR _selmonth =
    SELECTEDVALUE ( 'Table'[Month] )
RETURN
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month] = _selmonth ),
        CALCULATE ( SUM ( 'Table'[Cost] ) ),
        ,
        DESC,
        DENSE
    )

2. Create a table visual and apply a visual-level filter with the condition (Rank is 1)

vyiruanmsft_0-1696495385474.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mageto
New Member

Create a calculated column and use 'RANKX' with a filter using the earlier function ie 'table'[month]=earlier('table'[month]). This ensure cost ranking is grouped by month. Here's a rough sketch:

Rank =
RANKX(
    FILTER(
        'Rank',
        'rank'[Month] = EARLIER('rank'[Month])
    ),
    'rank'[Cost],
    ,
    DESC,
    Dense
)
Upto this point, you can use the cost column in a graph and add a chart level filter that only filters where your new rank column = 1. It will work perfectly.
If you need a table with only top ranks like you had shown above, you can create a new table that filters out where the rank column = 1. Here's how:
Top_Rank_Table = FILTER('Rank','Rank'[Rank]=1).
I hope this helps!

i have an error using the EARLIER Formula, show parameter is not correct.

 

My month column is from a calculated column

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors