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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Touliloop
Helper I
Helper I

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
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.