The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.