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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gtaranti
Frequent Visitor

Table.Combine : How to handle null values?

Hi all!

 

I want to merge ALL columns except the first one on the depicted table.

The column count is dynamic. There maybe more than these.

ss.png

 

I'm using the code :

= Table.CombineColumns(TransposedTable , List.Skip(Table.ColumnNames(TransposedTable ),1),  Combiner.CombineTextByDelimiter(" / ", QuoteStyle.None),"Merged")

to merge all columns except the 1st.

 

My probem is how to tackle null values, because in these rows I get :

Συγκατάθεση: Μέσω On-line φόρμας /  /  / Επεξεργασία απαραίτητη για την εκτέλεση σύμβασης 

(Sorry for the language, this is greek!)

 

Is there a function I can write to modify Combiner.CombinTextByDelimiter() in order to OMIT null values?

1 ACCEPTED SOLUTION
gtaranti
Frequent Visitor

A post in an other thread helped me to find my own solution.

 

Instead of Merging the columns at once, I added a custom column first that uses Text.Combine and at the same time removing NULLs, like that :

 

    AddedCustom = Table.AddColumn(Source ,  "Merged", (row) => Text.Combine( List.RemoveNulls(List.Skip(Record.FieldValues(row),1)), " / " )),

The community here is very helpful! Smiley Very Happy

View solution in original post

6 REPLIES 6
gtaranti
Frequent Visitor

A post in an other thread helped me to find my own solution.

 

Instead of Merging the columns at once, I added a custom column first that uses Text.Combine and at the same time removing NULLs, like that :

 

    AddedCustom = Table.AddColumn(Source ,  "Merged", (row) => Text.Combine( List.RemoveNulls(List.Skip(Record.FieldValues(row),1)), " / " )),

The community here is very helpful! Smiley Very Happy

Nice. I didn't know about that function.

stretcharm
Memorable Member
Memorable Member

You can use replace to change to a blank string

 

Enter null in the value to find.

 

= Table.ReplaceValue(#"Changed Type1",null,"",Replacer.ReplaceValue,{"YourColumn"})

Unfortunately replacing  null  with  blank string has the same effect.  

 

 "String1"  |  null  | "String2"   =>  String1 / / String2
 "String1"  |  ""  | "String2"   =>  String1 / / String2

Ah sorry, misread your request.

 

You can replace duplicate delimiters with a single one. If there is a chance you can have 3 then repeat the replace,

 

E.g.

/ /   to  /

 

 

 

If you have lots of colums and potential nulls you could pivot all but the first row, filter out nulls then unpivot back. However this is probably slower tha just replacing the duplicate delimiters.

Yes, I tried that, but there is also the problem with null in the first column.   (or multiple consecutive nulls).

 

 

This could be :  

null  |  "String1" | "String2"  =>   / String1 / String2

 

It's tough to get them all with replacements afterwards.

If I can't find a solution for omission of nulls DURING Table.Combine, I will go this path (i.e. replace all multiple delimeters and remove first & last ones)

 

Thanks..

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors