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?
You are on the right track, just some syntax:
if ([Source.Name] = "WB_Dispatcher-items.csv" or "WB_ExceptionQueue-items.csv" or "WB_ProcessorQueue-items.csv" or "WB_SendInvoice-items.csv") and [Started] <= #date(2021,4,9) then [Ended] else [Started]
So IF should be "if", and a date literal is #date(y,m,d). Added parentheses to the multiple "or" so that the last "or" doesnt become entangled with the "and".
--Nate
- Anonymous5 years agoNot applicable
Awesome - thank you for the quick reply. Just one question, my Start and End dates contain Time as well like so: "4/30/2021 1:57:00 PM" - Will I still be able to use that same syntax? I would assume not..