Forum Discussion
Anonymous
5 years agoNot applicable
Replace values in one column based on date range from another
Hi, Looking to replace all values 'X1' in column A with values 'X2' using M language. Can't duplicate column A. Condition is that only replace the values for date range between 01/01/20 to 06...
- 5 years ago
Hi, Anonymous
try the code below:
= Table.ReplaceValue( YouPreviousStepName, each [Date]>=#date(2020, 01, 01) and [Date]<=#date(2020, 06, 06), each [column A]="X1", (x,y,z)=>if y and z then "X2" else x, {"column A"} )
ziying35
Impactful Individual
5 years agoHi, Anonymous
try the code below:
= Table.ReplaceValue(
YouPreviousStepName,
each [Date]>=#date(2020, 01, 01) and [Date]<=#date(2020, 06, 06),
each [column A]="X1",
(x,y,z)=>if y and z then "X2" else x,
{"column A"}
)
- Anonymous5 years agoNot applicable
Thank you for this.