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
Anonymous
Not applicable

How do I RANKX over text duplicates?

Hi,

 

I've tried some of the examples of text rankings in this forums, with little to no success.

 

Here's what I'd like to achieve:

Gilladriel_0-1603011145000.png

My goal - filtering out all values that are different than 1 using a measure.
I can't use calculated columns because I'm using a Live Connection method over a Tabular Model.

 

Any help would be appreciated!

 

12 REPLIES 12
Anonymous
Not applicable

Anyone?

I'm still trying using RANKX using the index column, but every row gets the value 1 for some reason..

Can you describe more about the analysis you plan to do once you have the desired column?  I expect there is a different approach with DAX that you get your result with a live connection.

 

Regards,

Pat

 





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

As I've mentioned in my first message - my intention is to only show the rows with the value 1 (after ranking). I don't need to display the duplicates, any instance of a certain ID is enough for my analysis. 

 

So if this is my data:

ID         |     Desc

123           text1

123           text2

456           text1

 

I don't care which row of ID 123 gets rank #1.

I want to rank my entire table so every ID is displayed one time only. Super easy for me in SQL but seems impossible in DAX.

 

It probably isn't necessary to add the rank column.  For example, in a table visual you can just add the ID and Text columns and it will show only the unique combination of those columns (no duplicates).  Similarly, if you make a virtual table with SUMMARIZE(Table, Table[ID], Table[text]), you can do analysis on/from that (no duplicates).  Please decribe further what analysis you plan to do.

Regards,

Pat

 





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thank you @mahoneypat for bearing with me, but I feel like I'm not explaining myself correctly.

 

I do have unique rows in my table visual. If you could please take a look at the image I added - the ID '123' has three different text values. Each row of the three is unique, but I don't care for the other two. 

This is why I wanted to use a rank function, so I'd rank by ID in ascending order and filter out values that are greater than 1.

Anonymous
Not applicable

If I were to write it in SQL:

rank() over(partition by ID, order by Description) as rank.

 

Hope this clarifies.

 

Anyone please..?

One more suggestion.  Since you don't care with the three 123 text values is displayed, I would just make a table visual with the ID column and this measure

 

Text Values = MIN(Table[Description])

 

That will result in one row per ID and just one of the Description values.

 

Regards,

Pat

 





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


amitchandak
Super User
Super User

@Anonymous , As suggested by @mahoneypat , Add an index column and try a formula like

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

countx(filter(Table, [Index] <=earlier([index]) && [ID] = earlier([ID])),[ID])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

Hi, thanks for the help but I can't use "Edit Queries", because I'm using live connection, which disables that feature.

I also tried the COUNTX example but PBI throws an error, saying the syntax is wrong.

CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , with such few mockup data, I assume you'd like to seek a very similar solution like this thread

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Counting-number-of-continuos-same-entries/m-p/1439775#M26930


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

mahoneypat
Microsoft Employee
Microsoft Employee

Is there another column that can be used to tell which row is first (index, datetime, etc.)?  That will make it much easier to write the needed DAX measure.

Regards,

Pat

 





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat 

Hi, 

Ive found another unique column I can sort this by. What would the syntax be like?

I tried the suggestions below here to no avail..

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.