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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
PI2023
New Member

Replace duplicates with null

Hi everyone, 

 

I have a table that I need to remove the duplicates in the "Source.Name.1" column but keep the first value when it changes. So source name would be row 1 "1K2321C0172" and nulls until the value changes to "1K2321C0175" and so on at each occurance.

 

PI2023_1-1681910200444.png

 

2 REPLIES 2
Kmcdonald
Helper III
Helper III

Hi PI2023,

 

I think I've achieved what you need. Below what was starting point, I know you have a much bigger dataset but I thought that I'd show you it basic and you could cater it to your scenario. I just made some dummy data, with letters where some are duplicate and some not. I sorted it to show you a visual of how to do this.

 

Kmcdonald_0-1682213512066.png

Firstly, I added an index column starting from 1.

 

Kmcdonald_1-1682213623635.png

Then I added a custom column, which was just the index row minus 1. This gives you the previous row value.

 

Kmcdonald_2-1682213688262.png

Next I merged the query onto itself, referencing the previous row on the original query and the index on the new one.

 

Kmcdonald_3-1682213759697.png

Expand out the merge, by bringing only the original value column.

 

Kmcdonald_4-1682213854644.png

Then I added a conditional column, where if the two value columns are equal, then the output would be "null", otherwise bring over the original value.

 

Kmcdonald_5-1682213960230.png

Lastly, I removed all the unwanted columns, which has given the result of any duplicate with a null value.

 

Kmcdonald_6-1682214002042.png

 

pbix1
Resolver I
Resolver I

Hi PI2023

 

This link may help you. You need to have an index column. Then you could use an if statement to compare the value in the current row with the value in the next/previous row.

 

Value from previous row – Power Query, M language – Trainings, consultancy, tutorials (exceltown.com...

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors