Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
I’m trying to replace the date in column: [From] conditionally based on the value in column: [#"Resigned / Promoted"], if it is "Yes", the date in column: [From] would be increased by 10 days. I’ve used the below script but it doesn’t work, what is wrong with it?
= Table.ReplaceValue(#"Renamed Columns",each[From], each if [#"Resigned / Promoted"] = "Yes" then DateTime.LocalNow()+#duration(10,0,0,0) else [From], Replacer.ReplaceValue,{"From"})
Solved! Go to Solution.
I reproduced your scenario and your code worked for me. But why are you using DateTime.LocalNow() if you are trying to adjust the From value. Try this instead.
= Table.ReplaceValue(#"Renamed Columns",each[From], each if [#"Resigned / Promoted"] = "Yes" then [From] + #duration(10,0,0,0) else [From], Replacer.ReplaceValue,{"From"})
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
I reproduced your scenario and your code worked for me. But why are you using DateTime.LocalNow() if you are trying to adjust the From value. Try this instead.
= Table.ReplaceValue(#"Renamed Columns",each[From], each if [#"Resigned / Promoted"] = "Yes" then [From] + #duration(10,0,0,0) else [From], Replacer.ReplaceValue,{"From"})
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
You're absolutely right, it works! I've no idea why it wasn't working before, thanks a million.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 13 | |
| 11 | |
| 11 | |
| 8 | |
| 6 |