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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mp390988
Helper V
Helper V

Rank not working

Hi,

I am trying to rank clientId by the measure "2024 YTD" but i am getting all 1s.
So the rank is not working as expected.

 

mp390988_0-1753802321996.png


The defintion of my rank is as follows:

RankClients = RANKX(
    ALL(TradesTbl[ClientID]),
    [RevenueYTDForPrevYear],,
    DESC,
    Dense
)

 

 

And the definiton of the measure I am trying to rank by is defined as follows:

RevenueYTDForPrevYear = IF(
    NOT ISBLANK(
        CALCULATE(
            [Revenue],
            DATESBETWEEN(
                'CalendarTbl'[Date],
                DATE(
                    YEAR(TODAY())-1,
                    1,
                    1
                ),
                DATE(
                    YEAR(EOMONTH(TODAY(),-1))-1,
                    MONTH(EOMONTH(TODAY(),-1)),
                    DAY(EOMONTH(TODAY(),-1))
                )   
            )
        )
    ),
    CALCULATE(
        [Revenue],
        DATESBETWEEN(
            'CalendarTbl'[Date],
            DATE(
                YEAR(TODAY())-1,
                1,
                1
            ),
            DATE(
                YEAR(EOMONTH(TODAY(),-1))-1,
                MONTH(EOMONTH(TODAY(),-1)),
                DAY(EOMONTH(TODAY(),-1))
            )   
        )
    ),
    0
)
 

 


For the purpose of the visual I renamed this measure to "2024 YTD".

 

Not sure why my ranking is returning all 1s.

 

Thank You

1 ACCEPTED SOLUTION
v-nmadadi-msft
Community Support
Community Support

Hi @mp390988  ,
Thanks for reaching out to the Microsoft fabric community forum.

Please create a separate Table visual in your report and add only the 2024YTD and RankClients measures to it. This will help you determine whether the issue is with the measure logic itself or caused by unintended filters or interactions applied elsewhere in the report. By isolating the measures in a clean context, you can more easily pinpoint the root cause.

Additionally try modifying your DAX in such a way and check if the issue still persists

RankX_2 = 
VAR t = CALCULATETABLE(RankClients, REMOVEFILTERS(RankClients), VALUES(TradesTbl[ClientID]))
RETURN RANKX(t, [RevenueYTDForPrevYear] )



I hope this information helps. Please do let us know if you have any further queries.
Thank you

View solution in original post

8 REPLIES 8
v-nmadadi-msft
Community Support
Community Support

Hi @mp390988 

As we haven’t heard back from you, we wanted to kindly follow up to check if the suggestions  provided by the community members for the issue worked. Please feel free to contact us if you have any further questions.

 

Thanks and regards

v-nmadadi-msft
Community Support
Community Support

Hi @mp390988 

May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.


Thank you

v-nmadadi-msft
Community Support
Community Support

Hi @mp390988 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.


Thank you.

v-nmadadi-msft
Community Support
Community Support

Hi @mp390988  ,
Thanks for reaching out to the Microsoft fabric community forum.

Please create a separate Table visual in your report and add only the 2024YTD and RankClients measures to it. This will help you determine whether the issue is with the measure logic itself or caused by unintended filters or interactions applied elsewhere in the report. By isolating the measures in a clean context, you can more easily pinpoint the root cause.

Additionally try modifying your DAX in such a way and check if the issue still persists

RankX_2 = 
VAR t = CALCULATETABLE(RankClients, REMOVEFILTERS(RankClients), VALUES(TradesTbl[ClientID]))
RETURN RANKX(t, [RevenueYTDForPrevYear] )



I hope this information helps. Please do let us know if you have any further queries.
Thank you

Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

RankClients = RANKX(GENERATE(GENERATE(ALL(TradesTbl[ClientID]),ALL(TradesTbl[ClientName])),ALL(TradesTbl[DealerID]),ALL(TradesTbl[DelaerName]))[RevenueYTDForPrevYear],,DESC,Dense)

If this does not work, then share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mp390988
Helper V
Helper V

Hi @Greg_Deckler  - that does not make any difference

@mp390988 Can you share some sample data as text? Hard to know what exactly is going wrong. You might check out the RANK function as well as it can sometimes be less finicky than RANKX. You could also try an alternative to RANKX found here: To *Bleep* with RANKX! - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@mp390988 Try:

RankClients = RANKX(
    ALL(TradesTbl[ClientID]),
    CALCULATE( [RevenueYTDForPrevYear] ),,
    DESC,
    Dense
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors