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
Touliloop
Regular Visitor

Dynamic ranking use RANKX() show duplicates

I have a dataset "table" as follows:

Countrydatetimeeventchannelprice
UK2025-01-015BBC200
US2025-01-033ABC198

 

Purpose is to give all the channel a ranking, based on their #event_per_hour and € Cost per event . To do that I bulild the measures below and by rank the #event_per_hour desc and €cost_per_event asc, they receive two rankings, then I sum up the two rankings and got a score, at the end I sort the channel by the score asc to have the final ranking "§TOTAL RANKING".

 

Until sum the two rankings to get the score it works fine. But when I use the final measure § TOTAL RANKING, the weird thing happens, the total ranking doesn't sstart from 1 and has duplicates, see these examples:

Scorecurrent Total rankingexpected Total ranking
2ExcludedExcluded
751
7ExcludedExcluded
751
751
1162
1463

 

Can someone tell me what causes this problem and how to fix it? The visual is being filtered by the column "Country", each time one single selection of the slice "Country".

Measures:

  • # Channel_count = CALCULATE(COUNT(table[channel]))
  • # Sum_event = SUM(table[event)]
  • # event_per_hour= DIVIDE([# Sum_event], [# Channel_count],0)#
  • € Total cost = CALCULATE(SUM(table[price]))
  • € Cost per event = (DIVIDE([€ Total cost],[# Sum event],0))
  • Test_ranking_event =
         VAR FilteredTable =
         FILTER(
         ALLSELECTED(table [channel]),
         NOT(ISBLANK([# Channel_count])) // Ensures only valid rows are ranked
)
         RETURN
         IF([# Channel_count] <> BLANK(), CALCULATE(RANKX(FilteredTable, [# event_per_hour],, DESC)))
 
  • Test_rank_cost =
         VAR FilteredTable =
         FILTER(
         ALLSELECTED(table[channel]),
         NOT(ISBLANK([# Channel_count])) // Ensures only valid rows are ranked
)
       RETURN
       IF([# Channel_count] <> BLANK(), CALCULATE(RANKX(FilteredTable, [€ Cost per event ],, ASC)))
 
  • Score = table[Test_rank_cost] + table[Test_ranking_event]
  • § TOTAL RANKING=

    VAR FilteredTable =
    FILTER(
    ALLSELECTED(table[channel]),
    [€ Total cost] > 0 // Exclude zero-cost rows
    )
    RETURN
    IF([# Channel_count_2025] <> BLANK(), CALCULATE(IF(
    [€ Total cost] = 0,
    "EXCLUDED",
    RANKX(FilteredTable, [Score],, ASC)
    )))

           

1 ACCEPTED SOLUTION

Hi, thanks for your hint, I would like to close this querstion, I created a new one with sample data and better format.

View solution in original post

5 REPLIES 5
v-sshirivolu
Community Support
Community Support

Hi @Touliloop ,

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Please show the expected outcome based on the sample data you provided.

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Hi, thanks for your hint, I would like to close this querstion, I created a new one with sample data and better format.

Hi @Touliloop ,

 

To close the thread, click the three dots at the top right of the reply as shown below. Then, select the option to accept as solution.

vsshirivolu_0-1760001329461.png

 

Thank you.

 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi, thanks for your hint, I would like to close this querstion, I created a new one with sample data and better format. But I don't know how to close it. Could you please help to close it?

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors