Forum Discussion

GabinAM's avatar
GabinAM
Frequent Visitor
2 years ago
Solved

Add Rows - Loop

Hello everyone! 😊 Hope you're doing well!  Initial Situation I'm currently working on tricky DB, please see below an example, wtih some informations stored in columns (ID/Date/Underlying) a...
  • dufoq3's avatar
    2 years ago

    Hi GabinAM, Power Query solution:

     

    Result (you can delete last step if you want to see separate tables)

     

    let
        Source = Excel.Workbook(File.Contents("Z:\support\Execution\GAM\Control - Check - Data\20240408 - ADM New DB\Test 2\TEST.xlsx"), true, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        ChangedType = Table.TransformColumnTypes(Sheet1_Sheet,{{"ID", Int64.Type}, {"Label", type text}, {"Level", Int64.Type}, {"Date", type date}, {"Underlying", type text}}),
        GroupedRows = Table.Group(ChangedType, {"ID"}, {{"All", each Table.Pivot(_, List.Distinct([Label]), "Label", "Level"), type table}}),
        CombinedAll = Table.Combine(GroupedRows[All])
    in
        CombinedAll