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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
abehrmann
Helper II
Helper II

Replace null values with contents from another column

 

I am attempting to replace the null values with the values from completion note date in the far left. 

 

If possible i would like to use the exitsting completion date column instead of creating a new one. 

 

Any suggestions 

 

 

CompletionNotePIC.PNG 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

If a measure is sutible for your needs then a simple measure liek the following would work. Replace max with whatever aggregation you need

 

 

measure =
VAR _Column1 =
    MAX ( Column1 )
RETURN
    IF ( ISBLANK ( _Column1 ), MAX ( Column2 ), _Column1 )

If a measure is not sutible then the easiest way is to add a new column either in the model or in the Query Editor.

 

The DAX version would be 

 

Column3 =
IF ( ISBLANK ( Column1 ), Column2, Column1 )

The Power Query Version would be

 

 

if [Column1] = null then [Column2] else [Column1]

Then remove the old column. With Power Query you can do it in one step without adding a new column but it is not possible with the UI you need to use the advanced editor. I have included an example below, the key step is 

Table.ReplaceValue(#"Changed Type",null,each [Column1],Replacer.ReplaceValue,{"Column2"})

 

 

let
    Source = Table.FromRows({{1,null},{2,2},{3,3},{null,4},{5,null}}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,each [Column1],Replacer.ReplaceValue,{"Column2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"Column2", Int64.Type}})
in
    #"Changed Type1"

 

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

If a measure is sutible for your needs then a simple measure liek the following would work. Replace max with whatever aggregation you need

 

 

measure =
VAR _Column1 =
    MAX ( Column1 )
RETURN
    IF ( ISBLANK ( _Column1 ), MAX ( Column2 ), _Column1 )

If a measure is not sutible then the easiest way is to add a new column either in the model or in the Query Editor.

 

The DAX version would be 

 

Column3 =
IF ( ISBLANK ( Column1 ), Column2, Column1 )

The Power Query Version would be

 

 

if [Column1] = null then [Column2] else [Column1]

Then remove the old column. With Power Query you can do it in one step without adding a new column but it is not possible with the UI you need to use the advanced editor. I have included an example below, the key step is 

Table.ReplaceValue(#"Changed Type",null,each [Column1],Replacer.ReplaceValue,{"Column2"})

 

 

let
    Source = Table.FromRows({{1,null},{2,2},{3,3},{null,4},{5,null}}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,each [Column1],Replacer.ReplaceValue,{"Column2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"Column2", Int64.Type}})
in
    #"Changed Type1"

 

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors