Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Function to invoke function and append the outcome tables

Hello,   I have 2 tables that are like below:   - Table 1 list out volume of Product A and B last year by month - Table 2 list out volume of Product A and B this year by month   I the tables a...
  • v-kelly-msft's avatar
    5 years ago

    Hi  Anonymous ,

     

    First add a column with the Year number respectively to both tables:

     

    Then append tables in either one of the table:

    And you will see:

    Then create a function as below:

     

    let
        Source = (name) => let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY+7CoNQEET/5dYW7vouDSGFkKRIKRZGJE1IRGIgf59dF2ZvMzDn6jKn70MbktCNL0kKQ2L9NN8lGf08rpIZertoz6P3n2SB3m16r4z6U7Ly/7eHZI1+mxfJBv06fXRPCnB5fxX4wuM8KbCJB1fIAMyBcgCToALALKiMvlANqvzo7kF1BFSEGr+xm3AKYCpMAObCvtRc2JeaC8vS4Q8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, Month = _t, Volumn = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Month", type text}, {"Volumn", Int64.Type}}),
            #"Added Custom" = Table.AddColumn(#"Changed Type", "Year", each "Year 2021"),
            #"Appended Query" = Table.Combine({#"Added Custom", #"Year 2020"}),
            #"Product"=Table.SelectRows(#"Appended Query",each [Product]=name)
        in
            #"Product"
    in
        Source

     

     Finally you will see:

     

    For the related .pbix file,pls see attahced.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!