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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
biengineer
Helper I
Helper I

To Keep Duplicate Row but Delete Value from One

Dear All,

 

I have used merge Leftouter base one Col1 , Col2, Col3, I have duplicates in  this concatenation Col1-Col2-Col3, I want to keep the duplicate row but value in only one row resulted from Merge.

 

Best Regards. 

2 ACCEPTED SOLUTIONS
ImkeF
Super User
Super User

Hi @biengineer ,
if you use " try [Merged]{0} otherwise null " it should work.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

wdx223_Daniel
Super User
Super User

try this function

 

= Table.FuzzyNestedJoin(Table1,{Col1 , Col2, Col3},Table2,{Col1 , Col2, Col3},"n",JoinKind.LeftOuter,[Threshold=1,NumberOfMatches=1])

View solution in original post

7 REPLIES 7
wdx223_Daniel
Super User
Super User

try this function

 

= Table.FuzzyNestedJoin(Table1,{Col1 , Col2, Col3},Table2,{Col1 , Col2, Col3},"n",JoinKind.LeftOuter,[Threshold=1,NumberOfMatches=1])

Sir, I got error with data that it supports only text column, I converted date to text in both tables. And It has worked great with leftouter. 

 

Thanks for that.

 

I want to do it with fullouter, and import all the rows from the Table 2 while keeping all rows of Table 1. After this step wish to apply this step

 

=Table.FromRecords(List.TransformMany(Table.ToRecords(#"Merged Packing"),each Table.ToRecords([Packing]),(x,y)=>Record.RemoveFields(x,{"Packing"})&y))
ImkeF
Super User
Super User

Hi @biengineer ,
if you use " try [Merged]{0} otherwise null " it should work.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sir, I thought it worked, but still shows the duplicate value. 

 

= Table.AddColumn(#"Merged Packing", "Custom", each try [Packing]{0} otherwise null)

biengineer_0-1664423157851.png

 

 

= Table.ExpandRecordColumn(#"Added Custom7", "Custom", {"PackingQty"}, {"PackingQty"})

biengineer_1-1664423218514.png

 

Should have shown only 1229.

 

Best Regards.

 

 

Hi @biengineer ,

then my understanding of your requirement was wrong.
It might be that you need a right outer join instead, but still not sure about your exact requirements.
Also check out @wdx223_Daniel s solution. It does the job with just one join command.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

biengineer
Helper I
Helper I

Very closed it worked. how to handle the error where there is no match. Can i replace with zero during expansion.

 

Best regards 

ImkeF
Super User
Super User

Hi @biengineer ,
don't expand the column from the merge (imaging it is called "Merged"). Instead add a column that references that column and picks the first row from it: [Merged]{0}. Now expand this new column.
That will make sure that only the first row of the found matches will be returned and you will keep your original number of rows.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors