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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
murali5431
Helper III
Helper III

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 dateExpected date of Arrival
01-Aug-2001-Aug-20
 05-Aug-20
04-Aug-2004-Aug-20
 11-Aug-20

 

Thanks in advance for your support

 

Regards,

Muralidhar

1 ACCEPTED SOLUTION

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"})

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

9 REPLIES 9
MFelix
Super User
Super 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"})

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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

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.

 
 

Capture.PNG

 
 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix .. Thanks again!

 

I did as suggested, but I am still getting an error. I have provided a screenshot.

 Screenshot.jpg

Regards,

Muraldhar

What's the version you are using?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix .. I am using Version: 2.83.5894.661 64-bit (July 2020)

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"})

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks a ton... @MFelix .. It did work now.

 

Regards,

Muralidhar

Jimmy801
Community Champion
Community 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
    TransRow

 

Copy 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

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Top Solution Authors