Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.