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
Cyriackpazhe
Helper III
Helper III

RankX

Why am i getting the output like thisScreenshot (19).png

6 REPLIES 6
techies
Super User
Super User

pls try this - 

Measure =
VAR totalamount = [Enrollment Amount]

VAR QuarterRank =
    IF (
        ISINSCOPE ( 'DATE'[quarter]),
       RANKX (
            ALLSELECTED ( 'DATE'[quarter] ),
            [Enrollment Amount],
            ,
            DESC,
            DENSE
        )
    )
VAR Result =
    IF (
        NOT ISBLANK ( totalamount ),
        QuarterRank
    )
RETURN
    Result
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
bhanu_gautam
Super User
Super User

@Cyriackpazhe 

The issue you're encountering with the RANKX function in Power BI is likely due to the way the function is being used in conjunction with the ALL function. The ALL function removes all filters from the specified columns or tables, which can cause the RANKX function to rank all values as 1 because it is not considering any context for the ranking.

 

To fix this, you need to ensure that the RANKX function is applied in a context that allows it to rank the values correctly. 

DAX
RankX = RANKX(
ALL('Calendar'[Date], 'Calendar'[Quarter]),
[Total],
,
DESC,
DENSE
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I'm still getting incorrect result.I'm still getting incorrect result.Also if we do as you mentioned, won't the virtual table contain all possible combinations of year and quarter. The rank would be assigned as per its position in this entire set right

Anonymous
Not applicable

Hi @Cyriackpazhe , hello bhanu_gautam, thank you for your prompt reply!

 

Please try the following measure:

MeasureTotal = SUM('Table'[Total])
RankX = 
IF (
    ISINSCOPE ( 'Table'[Date].[Quarter] ),
    RANKX (
        FILTER (
             ALL('Table') ,
            YEAR ( 'Table'[Date] ) = YEAR ( MAX ( 'Table'[Date] ) )
        ),[MeasureTotal],,DESC
                ,
        DENSE
    ),
    IF (
        ISINSCOPE ( 'Table'[Date].[Year] ),
        RANKX (
            ALL ( 'Table' ),
            CALCULATE (
                SUM ( 'Table'[Total] ),
                ALLEXCEPT ( 'Table', 'Table'[Date].[Year] )
            ),
            [MeasureTotal],
            DESC,
            DENSE
        ),
        BLANK ()
    )
)

Result:

vyajiewanmsft_0-1739437831907.png

vyajiewanmsft_2-1739437846989.png

Best regards,

Joyce

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

but why isn't the meausre i wrote working. It should be correct right

 

Anonymous
Not applicable

Hi @Cyriackpazhe  , thank you for your feedback.

 

If possible, please update the sample pbix file without any sensitive information for further troubleshooting.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.