Forum Discussion

Trahan-Almighty's avatar
Trahan-Almighty
New Member
1 year ago
Solved

Need help to transform power query table

Hello,   I wish to transform this current table into grouped table. Is it possible do this in Power Query?    Thanks in advance,    Current table:    2022  2023  2024  2025 66 56 5...
  • wdx223_Daniel's avatar
    1 year ago

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        Custom1 = Table.UnpivotOtherColumns(Source,{},"Year","Value"),
        Custom2 = Table.AddColumn(Custom1,"Category",each List.Skip({{75,"75-100"},{50,"50-74"},{25,"25-49"},{0,"0-24"}},(x)=>x{0}>[Value]){0}?{1}?),
        Custom3 = Table.Pivot(Custom2,List.Distinct(Custom2[Year]),"Year","Value",List.Count)
    in
        Custom3