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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
salgouda
Frequent Visitor

Power Query replace column value based on another column

Hello there,

 

I am calculating employee retention and I need to change the null values in isActive column to be "false" if there's an end date which means the employee left, and "true" if end date is null which means the employee is still active.

 

Screenshot 2023-08-25 203544.png

 

this is the code I am using:

 

#"Replaced Value" = Table.ReplaceValue(#"Replaced OTH",each [isActive],each if [End Date] is null then "true" else [isActive],Replacer.ReplaceValue,{"isActive"})

 

but it doesn't seem to work.

 

Any tips? 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @salgouda ,
if you enter an equal sign just at the start, the formula should work.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
ImkeF
Community Champion
Community Champion

Hi @salgouda ,
if you enter an equal sign just at the start, the formula should work.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF
Community Champion
Community Champion

Hi @salgouda ,
the syntax looks correct. But the screenshot you have posted doesn't match your formula (-"...Copy" columns).
Otherwise: What does the error message says or what exactly is wrong with the current result you are getting?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi @ImkeF 

 

the original columns are just named isActive, and End Date

When I try to add a new custom step to write this code nothing happens!

 

it seems like I am missing something but can't figure out what is it?

1.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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