Forum Discussion
fill blank values with values in another column
Hi
I have done most of my calculations in power query editor.
As there are null values, I need to replace null values under Actual arrival date with values from Expected date of Arrival. How do I achieve this within power query editor.
As in below example, I need to fill rows 2 & 4 with the dates in Expected date of Arrival column
| Actual arrival date | Expected date of Arrival |
| 01-Aug-20 | 01-Aug-20 |
| 05-Aug-20 | |
| 04-Aug-20 | 04-Aug-20 |
| 11-Aug-20 |
Thanks in advance for your support
Regards,
Muralidhar
Hi murali5431 ,
Just realized that the you have made the incorrect formula is not case but Table.
= Table.ReplaceValue(#"Time to complete entry",each [Vessel_Actual_Arrival_Date__c], each if [Vessel_Actual_Arrival_Date__c] <> null then [Vessel_Actual_Arrival_Date__c] else [Vessel_Estimated_Arrival_Date__c],Replacer.Replacevalue,{"Vessel_Actual_Arrival_Date__c"})
9 Replies
- Jimmy801Community Champion
Hello murali5431
you can add a new column and make there a calculation like this
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUdSxN1zUyUNJBYsfqRCspgERMkUUMTJDUmqCrNUTojgUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Actual arrival date" = _t, #"Expected date of Arrival" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Actual arrival date", type date}, {"Expected date of Arrival", type date}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Actual arrival date new", each if [Actual arrival date]=null then [Expected date of Arrival] else [Actual arrival date]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Actual arrival date"}), #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Actual arrival date new", "Actual arrival date"}}) in #"Renamed Columns"or you can use Table.TransformRows like this
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUdSxN1zUyUNJBYsfqRCspgERMkUUMTJDUmqCrNUTojgUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Actual arrival date" = _t, #"Expected date of Arrival" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Actual arrival date", type date}, {"Expected date of Arrival", type date}}), TransRow = Table.FromRecords(Table.TransformRows(#"Changed Type",(row)=> if row[Actual arrival date]= null then Record.TransformFields(row, {"Actual arrival date", each row[Expected date of Arrival]}) else row)) in TransRowCopy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy - MFelixSuper User
Hi murali5431 ,
Add a custom step and use the following code:
= Table.ReplaceValue(Source,each [Actual arrival date],each if [Actual arrival date] <> "" then [Actual arrival date] else [Expected date of arrival],Replacer.ReplaceValue,{"Actual arrival date"})- murali5431Helper III
MFelix .. Thanks for the response!
I am getting error when I added a new custom column as below
"Expression.Error: The name 'Case.ReplaceValue' wasn't recognized. Make sure it's spelled correctly."
I enetered as follows where "Case" is table name:
= Case.ReplaceValue(source,each [Vessel_Actual_Arrival_Date__c], each if [Vessel_Actual_Arrival_Date__c] <> null then [Vessel_Actual_Arrival_Date__c] else [Vessel_Estimated_Arrival_Date__c],Replacer.Replacevalue,{"Vessel_Actual_Arrival_Date__c"})
The previous step is "Time to complete entry", in case it helps.
- MFelixSuper User
Hi murali5431 ,
First of all sorry for not refering that you must replace the Source by your previous step name so the values would be something similar to:
= Case.ReplaceValue(#"Time to complete entry",each [Vessel_Actual_Arrival_Date__c], each if [Vessel_Actual_Arrival_Date__c] <> null then [Vessel_Actual_Arrival_Date__c] else [Vessel_Estimated_Arrival_Date__c],Replacer.Replacevalue,{"Vessel_Actual_Arrival_Date__c"})
And this is not a new custom column you need to add a new custom step and then place this code on the formula bar, this will avoid creating new columns and deleting them.
Rigth click the last step on your query and then insert step after.