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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Birinder
Helper III
Helper III

How to get rid of duplicates values without removing values adjacent to them.

Suppose, I have a table like this:

 

Screenshot (22).png

 

And I want to turn it into this:

 

Screenshot (23).png

 

 

Is there any way of doing so.

I will appreciate all the help.

Thank you In Advance.

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewStep=#table(Table.ColumnNames(PreviousStepName),List.Accumulate(Table.ToRows(PreviousStepName),{{},""},(x,y)=>{x{0}&{List.RemoveLastN(y,1)&{if List.Last(y)=x{1} then null else List.Last(y)}},List.Last(y)}){0})

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

NewStep=#table(Table.ColumnNames(PreviousStepName),List.Accumulate(Table.ToRows(PreviousStepName),{{},""},(x,y)=>{x{0}&{List.RemoveLastN(y,1)&{if List.Last(y)=x{1} then null else List.Last(y)}},List.Last(y)}){0})

Thank you so much daniel. It worked as charm. 

However, I have various other columns to execute as same as above. 

As I remember the code, the code doesnt mention the column name. 

So, how Will I achieve this?

 

what is the frame of your data? and what is the rule of replacement? 

My data is like 8 columns and some rows.

Remember, what happens when we perform groupby and use some column as "SUM" aggregator while some columns to show all the rows instead of doing any aggregation?

The "All rows" aggregator repeats all the values for a specific column.

My need is to show the values of those columns only one time for each ID, not repetative.

Like in the screenshot above, You helped me in achieving each Brand name for each ID, despite having numerous model names.

I want to do the same with multiple columns. Like for 6-7 column at once.

If you have a different approach for this, feel free to enlighten me.

Thanks in Advance.

 

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.