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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
murali5431
Helper III
Helper III

Merge two power BI query steps

Hi,

 

I have a dataset which have a null values and then lots of duplicates in the same column. I need a power query step which would first filter filter out rows with duplicate values not impacting the rows with null values in this column.

 

When I did these steps separately, I got below. Is there a way I can combine it into a single step?

 

Unselected null values - #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
Removed rows where this column has duplicate values - #"Removed Duplicates" = Table.Distinct(#"Filtered Rows", {"Custom"})

 

Thanks,

Muralidhar

1 ACCEPTED SOLUTION

Hi @murali5431 ,

 

Try the follow query:

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlSK1YlWSsIgwUQyggkmUpDIVKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Column1"}),
    #"Removed Duplicates" = Table.FromRows(List.Distinct(Table.ToRows(#"Replaced Value"),each if _{0}=null then Text.NewGuid() else _{0}))
in
    #"Removed Duplicates"

 

image.pngimage.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@murali5431 , I think null ad duplicate in two-step is fine

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak I did them as two steps as suggested:

First filtered out null values, the removed duplicates. Now when I want to remove the filter for null values, I dont find the null value filter itself after second step. Can you please assist?

 

Thanks,

Muralidhar

Hi @murali5431 ,

 

Try the follow query:

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlSK1YlWSsIgwUQyggkmUpDIVKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Column1"}),
    #"Removed Duplicates" = Table.FromRows(List.Distinct(Table.ToRows(#"Replaced Value"),each if _{0}=null then Text.NewGuid() else _{0}))
in
    #"Removed Duplicates"

 

image.pngimage.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@amitchandak Thanks for the response! I would then need a third step to remove the filter for null values. Hence I felt it would be ideal to perform the duplicate removal as a single step.

 

Thanks again,

Muralidhar

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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