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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
csb
Frequent Visitor

Unique Serial Numbers even when we have duplicate records

Hi I need help to get unique serial number for the rows when I go  to drillthrough page as shown in the image.If it retrieves 10 rec then serial number should be 1 to 10. If 5 records then 1 to 5 .I tried below DAX function but it is giving duplicate values because same vendor name,same facility.But still I need get unique numbers.How can I achieve this??

Below are the DAX I used:

1.Measure

SN1 = CALCULATE(COUNTROWS('Reporting PosStarting2022'),FILTER(ALLSELECTED('Reporting PosStarting2022'),'Reporting PosStarting2022'[Vendor_Nbr] <=MAX('Reporting PosStarting2022'[Vendor_Nbr])))
 
2.Calculated Column
SN = RANKX(ALLSELECTED('Reporting PosStarting2022'),SELECTEDVALUE('Reporting PosStarting2022'[Vendor_Nbr]),,ASC,DENSE)

 

csb_1-1752854227317.png

 

Thanks..

 

 

 

 

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

If you try doing it with a dax measure then you get inconistent results depending on the filters.

Consider doing it in Power Query, so your reports will show a consistent serial number for the rows.

 

For example ...

 

Create some test data

speedramps_0-1752856126524.png

 

Group By Vendor using the Operator = All Rows

speedramps_1-1752856179959.png

Add a custom column

Table.AddIndexColumn([Count],"Index",1)

 

speedramps_2-1752856217603.png

Expand the Serial Number column

speedramps_3-1752856360993.png

Remove unneeded columns

speedramps_4-1752856405785.png

Congratualations, you now have a serial number for each row that restarts from 1 for each Vendor

 

Please click thumbs up because I have tried to help.

Then click [accept solution] if it works.

Thank you !

 

 

 

 

 

 

 

 

View solution in original post

6 REPLIES 6
v-sdhruv
Community Support
Community Support

Hi @csb ,

I hope the explaination provided, has addressed your query.
Since we didnt hear back, we would be closing this thread.
If you need any assistance, feel free to reach out again by creating a new post.

Thank you

v-sdhruv
Community Support
Community Support

Hi @csb ,
Just wanted to check if you got a chance to review the suggestions provided and whether that helped you resolve your query?

v-sdhruv
Community Support
Community Support

Hi @csb ,
Just wanted to check if you got a achance to review the suggestions provided and whether that helped you resolve your query?

Thank you @speedramps , @Greg_Deckler  and @Ashish_Mathur  for your insights to the query.


Ashish_Mathur
Super User
Super User

Hi,

This DAX pattern generates a serial number column

S. No. = ROWNUMBER(ALLSELECTED(Data),ORDERBY(Data[Date Presented]))
Hope this helps.
Ashish_Mathur_0-1752902344185.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

@csb This is a common problem with the ranking functions in DAX. You could investigate this solution for getting unique ranks: The Mythical DAX Index - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
speedramps
Super User
Super User

If you try doing it with a dax measure then you get inconistent results depending on the filters.

Consider doing it in Power Query, so your reports will show a consistent serial number for the rows.

 

For example ...

 

Create some test data

speedramps_0-1752856126524.png

 

Group By Vendor using the Operator = All Rows

speedramps_1-1752856179959.png

Add a custom column

Table.AddIndexColumn([Count],"Index",1)

 

speedramps_2-1752856217603.png

Expand the Serial Number column

speedramps_3-1752856360993.png

Remove unneeded columns

speedramps_4-1752856405785.png

Congratualations, you now have a serial number for each row that restarts from 1 for each Vendor

 

Please click thumbs up because I have tried to help.

Then click [accept solution] if it works.

Thank you !

 

 

 

 

 

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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