Forum Discussion

adelimont's avatar
adelimont
Regular Visitor
8 years ago
Solved

Rank top 10 data within each month

I'm new to Power BI and DAX and I haven't been able to find a solution to my problem.

 

I have a table organized with Job #, Month, Data. I would like to be able to add a column to rank the data within each month. Then when selecting a specific month in my visuals I can see the ranking for the data for that month.

 

Table name is '2018 YTD'.

 

 

So far I haven't been able to use the FILTER function to get a usable result. I can get the rank of all the data in the REVENUE column, but I can't get it broken down by month so that each month has a ranking of 1 through 10.

 

Rank Revenue by Month = if(rank.eq('2018 YTD'[Revenue],'2018 YTD'[revenue],DESC)<11,rank.eq('2018 YTD'[Revenue],'2018 YTD'[Revenue],DESC),0)

 

Thank you for your help!

  • HI adelimont

     

    Try this column

     

    Rank Revenue by Month =
    RANKX (
        FILTER ( 'YTD', 'YTD'[Month] = EARLIER ( 'YTD'[Month] ) ),
        'YTD'[Revenue],
        ,
        DESC,
        DENSE
    )

3 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    HI adelimont

     

    Try this column

     

    Rank Revenue by Month =
    RANKX (
        FILTER ( 'YTD', 'YTD'[Month] = EARLIER ( 'YTD'[Month] ) ),
        'YTD'[Revenue],
        ,
        DESC,
        DENSE
    )
  • Phil_Seamark's avatar
    Phil_Seamark
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi adelimont

     

    This calculated column will be pretty close.  Let me know if you would like this as a calculated measure

     

     

    Rank Revenue as Column = 
         RANKX(
                FILTER(
                    '2018 YTD',
                    '2018 YTD'[Month] = EARLIER('2018 YTD'[Month])),
                '2018 YTD'[Revenue]
                )