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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
christopherocc
Frequent Visitor

How to Conditionally Replace Values in Power Query?

There is some jumbled data in this table I'm working on. I have two columns in question. SubmittedDate and SubmissionType. I want to do the following:

 

- If SubmittedDate is null and SubmissionType is not 'Initial', I want to fill SubmittedDate with the value from SubmissionType.

- If SubmittedDate is null and SubmissionType is 'Initial', I want to leave SubmittedDate as it is.

 

Is there a way to do achieve this? Is there a different approach? I would prefer to keep cleaning in Power BI.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @christopherocc 

Please try the following code:


let
    Source = YourDataSource,
    #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"SubmittedDate"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "NewSubmittedDate", each if [SubmittedDate] = null and [SubmissionType] <> "Initial" then [SubmissionType] else [SubmittedDate]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"SubmittedDate"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"NewSubmittedDate", "SubmittedDate"}})
in
    #"Renamed Columns"

 

vjialongymsft_0-1733708085029.png                 

  

vjialongymsft_3-1733709938830.png

 

 

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @christopherocc 

Please try the following code:


let
    Source = YourDataSource,
    #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"SubmittedDate"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "NewSubmittedDate", each if [SubmittedDate] = null and [SubmissionType] <> "Initial" then [SubmissionType] else [SubmittedDate]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"SubmittedDate"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"NewSubmittedDate", "SubmittedDate"}})
in
    #"Renamed Columns"

 

vjialongymsft_0-1733708085029.png                 

  

vjialongymsft_3-1733709938830.png

 

 

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Deelip
Resolver I
Resolver I

Hi @christopherocc 

 

There is a work around for that by adding conditional column with your logic and after that you can remove your original submission date column and keeping your conditional column as submission date. 

Or you can use the below query in a new custom column as 

each if [SubmittedDate] = null and [SubmissionType] <> "Initial" then [SubmissionType]
else [SubmittedDate]

Thanks!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors