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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
gjohnson900
Helper I
Helper I

RANKX() over multiple columns?

I've got this as incoming data...

 

tabledata.JPG

 

I'm sending the data to a Sankey chart, where the "weight" is the DISTINCTCOUNT of customerkeys.  I want to be able to offer the user a Top N chiclet slicer to keep the chart readable.  To that end, I created a computed measure [dRanker], that will RANKX the number of customers over my [source] values...

 

guts.JPG

 

The problem is that the Sankey chart needs both a [source] and a [dest] to make it useful.  When I add a visual filter on the Sankey to only show where dRanker is <= 2, I get 9 different [source] values, not just the 2 highest ranked...

 

nine.JPG

 

 

When I add [dest] to my data table, I can see that many more [source]s are getting RANKed as <= 2...  

 

cactus.JPG

 

I'm guessing that's why I'm getting so many results in the Sankey as well, so...  How do I tell RANKX() that I want it to rank over the DISTINCTCOUNT of CustomerKeys for BOTH [source] and [dest]?  I feel like the tSQL RANK() function allows this, but I can't seem to find similar overload functionality for RANKX() in DAX.

 

Another approach that would be just as good...  How could I get the Sankey chart to only show [source] values that appear in the original table above where the [source] ranking is correct?

 

Here's the dRanker DAX...

dRanker = RANKX(ALLSELECTED(FW17[source]), [CustCount])

... and the [CustCount] calculated measure...

CustCount = DISTINCTCOUNT(FW17[customerkey])

Am I thinking about this wrong?  What's wrong with my brain.  It's usually pretty good.

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @gjohnson900

First you need to detemine how to calcuate the DISTINCTCOUNT of customerkeys, in your previous step, you just add the column [customerkeys] to the table  and select "count(distinct)", right? in this way, the result will change with the columns you add to the table.

3.png

Thus your [Rank] column also become different.

So first please let me know how you would like the DISTINCTCOUNT of customerkeys.

 

Best regards

maggie

Helpful resources

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

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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