Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Power Query Replace null values with values from another column

Tags:

powerquery

m

I am working with data imported from a pdf file. There is an extra column in the Power Query import (Data.Column7), containing data that belongs in the adjacent columns on either side (Data.Column6 and Data.Column8). Columns 6 and 8 have null values in the cells where the data was pushed into Column 7. I would like to replace the null values in Columns 6 and 8 with the correct data from Column 7, leaving all other values Columns 6 and 8 as is.

After looking at the post here: Power Query / Power BI - replacing null values with value from another column

and watching this video: https://www.youtube.com/watch?v=ikzeQgdKA0Q

I tried the following formula:

= Table.ReplaceValue(#"Expanded Data",null, each _[Data.Column7] ,Replacer.ReplaceText,{"Data.Column6","Data.Column8"})

(Note, "Expanded Data" is the last step before this Replace Value step.)

I am not getting any kind of syntax error, but the Replace Value step isn't doing anything at all. My null values in Columns 6 and 8 have not been replaced with the correct data from Column 7.

Any insight into how to achieve replacement would be greatly appreciated. Thank you.

(I should mention, I am a new Power Query user, so please be detailed and assume I know nothing!)

like image 262
Qqqqq Avatar asked May 03 '26 21:05

Qqqqq


1 Answers

I was looking for a solution for this, and I was able to do it as follows (based on provided example):

= Table.ReplaceValue(#"Expanded Data",null, each _[Data.Column7] ,Replacer.ReplaceValue,{"Data.Column6","Data.Column8"})

The difference then is the use of Replacer.ReplaceValue instead of Replacer.ReplaceText.

I noticed the _ after each is not required.

like image 189
Sion Oppeneer Avatar answered May 07 '26 11:05

Sion Oppeneer