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
Walter_W2022
Resolver II
Resolver II

How to remove duplicates for each row and then shift columns to right in Power Query

Hi there,

Need help here, how can I convert below in Power Query? need to remove the duplicates in the right columns, then shift the columns without duplicates from left to right for each row

wangbt89_0-1688687820829.png

Thanks in advance!

Cheers

Walter

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Walter_W2022 ,

 

Here you can open the advanced editor:

vcgaomsft_0-1688968141373.png

To the left of the "=" sign are the names of the individual steps; if they contain special characters (e.g. spaces), they must be nested outside #"".

vcgaomsft_1-1688968433814.png

Our previous step name was #"change type", so here we replace PreviousStepName with #"change type" and you can replace this step name as required.

vcgaomsft_2-1688968810331.png

Finally we need to return the result of the Custom1 step, so the result after in needs to be changed to Custom1.

Result.

vcgaomsft_3-1688968933920.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

NewStep=#table(Table.ColumnNames(PreviousStepName),Table.ToList(PreviousStepName,each let a=List.Count(_) in List.LastN(List.Repeat({null},a)&List.Distinct(_),a)))

Thank you for your reply, sorry, I could not make it work, would you please explain a bit more? as I am not familiar with M code. especially what does #table mean? how should I replace it?

Anonymous
Not applicable

Hi @Walter_W2022 ,

 

Here you can open the advanced editor:

vcgaomsft_0-1688968141373.png

To the left of the "=" sign are the names of the individual steps; if they contain special characters (e.g. spaces), they must be nested outside #"".

vcgaomsft_1-1688968433814.png

Our previous step name was #"change type", so here we replace PreviousStepName with #"change type" and you can replace this step name as required.

vcgaomsft_2-1688968810331.png

Finally we need to return the result of the Custom1 step, so the result after in needs to be changed to Custom1.

Result.

vcgaomsft_3-1688968933920.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

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.

Top Solution Authors