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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Super User
Super User

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
Super User
Super User

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
Super User
Super User

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.