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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Yiyi
Helper I
Helper I

Why a calculated table can not be ranked with RANKX()? The result is 1 for every rows!

Hello friend, 

 

Could you kindly help me to figure out how to rank a calculated table? 

 

I have one table as my original table and based on the original table, I have created a new table to count unique values for each media. I have also added a rank for the new table. The DAX is as follows: 

 

 
SummarizedTable =
    ADDCOLUMNS(
        SUMMARIZE(
            ALLSELECTED(Data),
            Data[Media],
            "Unique_Item_Count", DISTINCTCOUNT(Data[HeadlineID])
        ),
        "Rank",
        RANKX(ALLSELECTED(Data[Media]), [Unique_Item_Count], , DESC,Dense)
    )

 The result I got is as follows: 

Yiyi_0-1690887955869.png

I really appreciate if you could help! Thank you.

1 ACCEPTED SOLUTION
eliasayyy
Memorable Member
Memorable Member

please try 

SummarizedTable = 
VAR _t =
        SUMMARIZE(
            ALLSELECTED('Table'),
            'Table'[Media],
            "Unique_Item_Count", SUM('Table'[Count])
        )
RETURN
ADDCOLUMNS(
    _t,
    "Rank",
    RANKX(_t,[Unique_Item_Count],,DESC,Dense)
)

annonymous1999_0-1690889153594.png

 

annonymous1999_1-1690889209094.png

 



View solution in original post

5 REPLIES 5
eliasayyy
Memorable Member
Memorable Member

please try 

SummarizedTable = 
VAR _t =
        SUMMARIZE(
            ALLSELECTED('Table'),
            'Table'[Media],
            "Unique_Item_Count", SUM('Table'[Count])
        )
RETURN
ADDCOLUMNS(
    _t,
    "Rank",
    RANKX(_t,[Unique_Item_Count],,DESC,Dense)
)

annonymous1999_0-1690889153594.png

 

annonymous1999_1-1690889209094.png

 



SummarizedTable = VAR _t= SUMMARIZE( ALLSELECTED('Main Data'), 'Main Data'[Media], "Unique_Item_Count", DISTINCTCOUNT('Main Data'[HeadlineID]) ) RETURN RANKX(_t,[Unique_Item_Count]+RAND(),,DESC,Dense)

Hello thanks for your help again! I am trying to get the ranks for the running total calculation thus I need the ranks to be distinct number. I found somewhere saying that by using RAND() might help to achieve such result. Do you know how to do it? Thanks a millions time! 

Spoiler
 

If you are having trouble with dense and having same rank , it is true you can use rand() which will add a decimal to the total value so [unique measure] + rand() should lpwer the change to get same rank

works perfectly, you are like a magician 😉 Thanks a lot 😊

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.