Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Conditionally Skip an Applied Step

I have a table that I want to output 4 columns sometimes and 5 columns other times.  I want to write something that will conditionally skip a merge statement in the advanced editor.  Is this possible...
  • spinfuzer's avatar
    spinfuzer
    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