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.
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