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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
venstart
Frequent Visitor

Power Query (BI) replace date from another column

I need help with Power Query (BI) replace date from another column if the not NULL

 

So i got two columns in my table on Power BI, I will add a custom FX

 

First Column : Date

Second Column : TransformedDate

 

Now on the " TransformedDate " column there are dates and NULL values, I want to copy the values of the " TransformedDate " which are NOT NULL and replace it to the " Date " column

venstart_0-1609870675201.png

 

 

FYI: My last custom step --> = #"Sorted Rows"

 

How to resolve this. Send me the query code

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@venstart 

You may add a conditional column as below:

V-pazhen-msft_2-1610002119678.png

 

V-pazhen-msft_1-1610002025044.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

@venstart 

You may add a conditional column as below:

V-pazhen-msft_2-1610002119678.png

 

V-pazhen-msft_1-1610002025044.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

AlB
Community Champion
Community Champion

Hi @venstart 

Place the following M code in a blank query to see the steps:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA3MAQiJR0lpVgdJBEjoAiYY2ikb2SEKmeModoErhrIN1eKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, TransformedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"TransformedDate", type date}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Date", Order.Ascending}}),

    #"Added Custom" = Table.AddColumn(#"Sorted Rows", "Custom", each if [TransformedDate]<> null then [TransformedDate] else [Date], type date),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Date"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Date"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Date", "TransformedDate"})
in
    #"Reordered Columns"

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

ToddChitt
Super User
Super User

You could do this by inserting a new Custom Conditional Column.

 

IF [TransformedDate] equals null THEN Date

Else TransformedDate

 

The M code looks like this:

#"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [TransformedDate] = null then [Date] else [TransformedDate])

 

But use the GUI for adding a new Conditional Column, it's easier.

 

Hope that helps.




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Hi @ToddChitt 

Thank you for your reply

 

However, I dont want to replace the TransformedDate.

 

But want to replace/copy values of the " TransformedDate " which are NOT NULL (meaning with date values only from TransforedDate) and replace it to the " Date " column

 

My last custom step --> = #"Sorted Rows"

 

How to resolve this. Send me the query code

Have you looked at the Conditional Column options? You can still do this.

 

What is the Condition? (the "IF" part)? [TransformDate] IS NULL 

What is the Output if the Condition is evaluated to TRUE? (The THEN part)?

What is the Output if the Condition is evaluated to FALSE (The ELSE part)?

 

One way or another, you are goig to need to 1) Create a new Conditional column, 2) remove one or both of the originating columns, and 3) re-name the new column so it takes the place of one of the original ones.

 

Try writing out your logic in your native language:

 

IF [Transform date] IS NULL, then I want [Date], otherwise I want [Transform Date]

Or is it something else?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Can I send you the power bi file so that you can check the 2 column in the table

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.