I need to branch code in M, and I found Chris Webb's helpful blog post here. However, I don't want an ELSE clause in the code but M is demanding one, so I didn't know if there's a way to "dummy" a line so that I can continue execution.
I have large files with years of data that take forever to load, but for testing purposes I'd like to just take the last x days of my source files. I have a parameter table in the spreadsheet with an Override value (Y/N) and the days of history I want to load. The function fnGetWorkbookParameter will call the respective values.
My M code is thus:
...
AddConvFactor -= Table.AddColumn(...)
IsOverride = fnGetWorkbookParameter("Data History Override"),
OverrideDuration = fnGetWorkbookParameter("Days History"),
IfDateOverride = if IsOverride = "Y"
then Table.SelectRows(AddConvFactor, each Date.IsInPreviousNDays([PO Date], OverrideDuration))
else "No change",
ChangeConvFactorType = Table.TransformColumnTypes(IfDateOverride, ...)
...
In the "true" portion of my IF clause I can reference the prior part of the query up to step AddConvFactor, and the next step outside the IF clause references that step. But if I run my code without the override I have to use the ELSE clause with a dummy statement I don't want to use.
I'm not sure if there is a way to not need the ELSE clause, or what I should put there. Just set a variable I don't care about?
I have large files with years of data that take forever to load, but for testing purposes I'd like to just take the last x days of my source files. I have a parameter table in the spreadsheet with an Override value (Y/N) and the days of history I want to load. The function fnGetWorkbookParameter will call the respective values.
My M code is thus:
...
AddConvFactor -= Table.AddColumn(...)
IsOverride = fnGetWorkbookParameter("Data History Override"),
OverrideDuration = fnGetWorkbookParameter("Days History"),
IfDateOverride = if IsOverride = "Y"
then Table.SelectRows(AddConvFactor, each Date.IsInPreviousNDays([PO Date], OverrideDuration))
else "No change",
ChangeConvFactorType = Table.TransformColumnTypes(IfDateOverride, ...)
...
In the "true" portion of my IF clause I can reference the prior part of the query up to step AddConvFactor, and the next step outside the IF clause references that step. But if I run my code without the override I have to use the ELSE clause with a dummy statement I don't want to use.
I'm not sure if there is a way to not need the ELSE clause, or what I should put there. Just set a variable I don't care about?