Forum Discussion
Replace dates lower than a specific date by null
Hi All,
I am trying to replace dates in my dataset. I need to replace every date lower than 2015.1.1 by null.
The code works fine and I would like to extend the function to multiple columns. In my current scenario, these columns are the following"TS01_stock_take_date" and "TS02_creation_date".
Thanks in advance for your advise.
Cheers
= Table.ReplaceValue(#"Merged Columns", each [TS01_stock_take_date] , each if [TS01_stock_take_date] < #date(2015,1,1) then null else [TS01_stock_take_date],Replacer.ReplaceValue, {"TS01_stock_take_date"})
- Anonymous6 years ago
Hi Arnault_ ,
I guess, one option would be to replace value on the other tab as a separate (second) step.
If you something like "mass" change, you need to replace the standard Replacer function, and pass a list of columns to apply to.
Replacer function takes 3 agruments: x is your actual value from the column, y comapare to, z replace by.
Table.ReplaceValue(#"Changed column type", #date(2015,1,1), null, (x,y,z) => if x < y then z else x, {"TS01_stock_take_date", "TS02_creation_date"})Kind regards,
JB
5 Replies
- Jimmy801Community Champion
Hello Arnault_
you have to use a Table.TransformColumns. Check out this code (not tested)
= Table.TransformColumns ( #"Merged Columns", { { "TS01_stock_take_date" , (datecheck)=> if datecheck < #date(2015,1,1) then null else datecheck, type date } } )
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy- AnonymousNot applicable
Hi Arnault_ ,
I guess, one option would be to replace value on the other tab as a separate (second) step.
If you something like "mass" change, you need to replace the standard Replacer function, and pass a list of columns to apply to.
Replacer function takes 3 agruments: x is your actual value from the column, y comapare to, z replace by.
Table.ReplaceValue(#"Changed column type", #date(2015,1,1), null, (x,y,z) => if x < y then z else x, {"TS01_stock_take_date", "TS02_creation_date"})Kind regards,
JB