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 August 31st. Request your voucher.

Reply
JoeCrozier
Helper II
Helper II

Add suffix to column in Power Query if duplicates

Hello!

   I have data that looks like this:

JoeCrozier_0-1697645484405.png

I want to pivot it to look like this:

JoeCrozier_1-1697645511405.png

I.e. "completed date"'s become the values for the rows of protocol id's and columns of milestones.

As you can see, it pretty much works.  Problem is, every once and a while I have duplicates like this:

JoeCrozier_2-1697645582482.png


Where for a specific combination of protocol_id and milestone, I'll have two different dates.   I can clean up my data for now, but knowing the data source, it'll happen again.

 

So I was thinking one way to handle this might be to 'tag' them with indexes, maybe like this:

JoeCrozier_3-1697645685090.png

 

So that when I pivot it, I'll get a few more columns.  I may not use ALL of the columns, but at least I wont have errors.


I tried to follow this article to do so: https://excelguru.ca/label-duplicates-with-power-query/

 

but right when I got to the 

  • Table.AddIndexColumn( [Data] , "Instance" , 1 )  step--- i started getting errors, specifically this one:
  • JoeCrozier_4-1697645866750.png

     

I wonder if it has something to do with the way i grouped (by two variables).  Any ideas or suggestions?




 

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

I think that's just telling you it doesn't know what [Data] is in that line.

Just from observation, it looks like the formula has been entered directly in the formula bar instead of in the Add Custom Column dialog.  I'm sure it will get wrapped with a reference to the previous query step if you do that.

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

I think that's just telling you it doesn't know what [Data] is in that line.

Just from observation, it looks like the formula has been entered directly in the formula bar instead of in the Add Custom Column dialog.  I'm sure it will get wrapped with a reference to the previous query step if you do that.

Lol.  It was as simple as that, thank you.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.