Forum Discussion
Conditionally Skip an Applied Step
- 2 years ago
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), ChangedType = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}), choice1 = let next1 = Table.AddColumn(ChangedType, "Column2", each [Column1] + 1), final1 = Table.AddIndexColumn(next1, "Index" ) in final1, choice2 = let next2 = Table.AddColumn(ChangedType, "Column2", each [Column1] + 5), final2 = Table.NestedJoin(next2, "Column1", next2, "Column1", "NestedJoin" ) in final2, conditional_stmt = if Time.Second(DateTime.LocalNow()) > 30 then choice1 else choice2 in conditional_stmt
You can do an if condition then Table.NestedJoin .... else then PriorStep
Or you can do a
try Table.NestedJoin(.....) otherwise PriorStep
if you want it to try to merge and if it fails then do something else.
I believe I tried that .. could you provide an example or the syntax? I don't think you can just write a contitional like that straight in the advanced editor. It's not just one step that I'm trying to skip. I'm trying to skip 5-6 steps that transform that column after it is merged too.
- spinfuzer2 years ago
Solution Sage
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), ChangedType = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}), choice1 = let next1 = Table.AddColumn(ChangedType, "Column2", each [Column1] + 1), final1 = Table.AddIndexColumn(next1, "Index" ) in final1, choice2 = let next2 = Table.AddColumn(ChangedType, "Column2", each [Column1] + 5), final2 = Table.NestedJoin(next2, "Column1", next2, "Column1", "NestedJoin" ) in final2, conditional_stmt = if Time.Second(DateTime.LocalNow()) > 30 then choice1 else choice2 in conditional_stmt- Anonymous2 years agoNot applicable
This worked brilliantly. Thank you!
- spinfuzer2 years ago
Solution Sage
on second thought, you might want to put the steps directly in the if then statement because they will both run and reduce execution speed because you are running unncessary steps. If you put them only in the if statement the second part will only run when the first part fails.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), ChangedType = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}), conditional_stmt = if Time.Second(DateTime.LocalNow()) > 30 then let next1 = Table.AddColumn(ChangedType, "Column2", each [Column1] + 1), final1 = Table.AddIndexColumn(next1, "Index" ) in final1 else let next2 = Table.AddColumn(ChangedType, "Column2", each [Column1] + 5), final2 = Table.NestedJoin(next2, "Column1", next2, "Column1", "NestedJoin" ) in final2 in conditional_stmt