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?
I must be slipping, my code is not even code! Try:
Table.AddColumn(Table, "CorrectedStart", each if ([Source.Name] = "WB_Dispatcher-items.csv" or [Source.Name] = "WB_ExceptionQueue-items.csv" or [Source.Name] ="WB_ProcessorQueue-items.csv" or [Source.Name] ="WB_SendInvoice-items.csv") and [Started] <= #datetime(2021,4,9,0,0,0) then [Ended] else [Started]
Question for you, would
each if [StartTime] > [EndTime] then [Endtime] else [StartTime]
be easier?
This was perfect. Thank you so much for your expertise.