Forum Discussion
Help with M Code Syntax | IF Statement based on a couple of columns | Data Cleansing
- Anonymous5 years ago
Nate - thanks so much. This perfectly worked out when the only 4 available fields in source.name was one of the 4 flawed CSVs. When I try to use this on the whole dataset including the other Queue Names in the source.name column, I get errors. Is there a way to include in the function that "if any other name shows up in source.name, then just bring back the normal START date?
Well, M allows us to compare date to DateTime, but just to be sure, change it to:
if ([Source.Name] = "WB_Dispatcher-items.csv" or "WB_ExceptionQueue-items.csv" or "WB_ProcessorQueue-items.csv" or "WB_SendInvoice-items.csv") and [Started] <= #datetime(2021,4,9,0,0,0) then [Ended] else [Started]
So now it's a datetime instead of a date.
--Nate
Nate - thanks so much. This perfectly worked out when the only 4 available fields in source.name was one of the 4 flawed CSVs. When I try to use this on the whole dataset including the other Queue Names in the source.name column, I get errors. Is there a way to include in the function that "if any other name shows up in source.name, then just bring back the normal START date?