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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
danextian
Super User
Super User

Combine text from all available columns into one in Power Query

Hi All,

 

I've been trying to solve this on my own with no luck.

 

I have a table with many columns. Some colums have nulll values, some don't. I want to remove all rows with just null values in all columns. Column is nulll, column 2 is null, column 3 is null so on and so forth... so if the concatenation of all these columns result to null, the row will be removed. 

 

I wan to do the concatenation without having combine the columns one by one using ampersands or Text.Combne and Text.From

Would be great if this is possible.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
2 ACCEPTED SOLUTIONS

You can just remove blank rows:

 

Remove blank rows.png

 

Resulting code:

let
    Source = Table.FromColumns({{1,null,3},{null,null,null}},type table[Number1 = number, Number2 = number]),
    #"Removed Blank Rows" = Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
in
    #"Removed Blank Rows"

This checks both on nulls and "". If you only want to check for nulls, then you can adjust the code accordingly.

 

Specializing in Power Query Formula Language (M)

View solution in original post

v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @danextian,

I reproduce using my simple table.

1.PNG

You can create a custom column using the formula.

2.PNG
Then remove the rows based on the custom column. Please see my Query statement below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lEysQASQFasDlDAFMgGIkswDyRuZAwkLSCSRhCFOkrmMGkQAjFNwEqBhJlSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}, {"Column3", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if(([Column1]=null)and([Column2]=null)and([Column3]=null)) then null else 1),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Custom] <> null and [Custom] <> "")
in
    #"Filtered Rows"


I will get the expected result.

4.PNG

Best Regards,
Angelia

 

View solution in original post

3 REPLIES 3
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @danextian,

I reproduce using my simple table.

1.PNG

You can create a custom column using the formula.

2.PNG
Then remove the rows based on the custom column. Please see my Query statement below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lEysQASQFasDlDAFMgGIkswDyRuZAwkLSCSRhCFOkrmMGkQAjFNwEqBhJlSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}, {"Column3", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if(([Column1]=null)and([Column2]=null)and([Column3]=null)) then null else 1),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Custom] <> null and [Custom] <> "")
in
    #"Filtered Rows"


I will get the expected result.

4.PNG

Best Regards,
Angelia

 

vanessafvg
Super User
Super User

@danextian never tried it myself but @MarcelBeug has given me a formula before with list in power query maybe that can help?

 

https://msdn.microsoft.com/en-us/library/mt296612.aspx





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




You can just remove blank rows:

 

Remove blank rows.png

 

Resulting code:

let
    Source = Table.FromColumns({{1,null,3},{null,null,null}},type table[Number1 = number, Number2 = number]),
    #"Removed Blank Rows" = Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
in
    #"Removed Blank Rows"

This checks both on nulls and "". If you only want to check for nulls, then you can adjust the code accordingly.

 

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.