Forum Discussion
Power Query combining NULL values
- 6 years ago
Use the following logic in Power Query:
= [Column1] & (if [Custom] = null then "" else [Custom])It is critical you wrap the if/then/else construct in parentheses, or you'll get an error about a literal being expected. This will return the entire if/then/else as a literal, then allow you to concatenate with your other column.
Then mark that new column as text, and bring it into Power BI's DAX model.
Use the following logic in Power Query:
= [Column1] & (if [Custom] = null then "" else [Custom])
It is critical you wrap the if/then/else construct in parentheses, or you'll get an error about a literal being expected. This will return the entire if/then/else as a literal, then allow you to concatenate with your other column.
Then mark that new column as text, and bring it into Power BI's DAX model.
- vsolanon6 years agoFrequent Visitor
Thank you so much edhans it worked like a charm 🙂
I am new in PowerBi and will start reading more about this properties to use 🙂
- edhans6 years agoCommunity Champion
Great! Glad it helped.
- GMY3 years agoNew Member
It's work, but if you have several columns with null values it can became unreadable.
I create a function "IsNull" (sorry variables are in french)
let IsNull = (Valeur,RetourSiNull)=> let ValeurRetournee = if Valeur=null then RetourSiNull else Valeur in ValeurRetournee in IsNullYou use like this
= [Column1] & IsNull([Custom], "")I use this function to avoid null in calculus (IsNull([Custom],0) or comparaison (IsNull([Custom],"")="").
I hope this will be helpfull.
Guy
- munchkin6662 years agoHelper II
edhans worked for me. Thank you!
- edhans2 years agoCommunity Champion
Great munchkin666 !