Forum Discussion

Nozama's avatar
Nozama
Helper I
1 year ago
Solved

Pivot/Unpivot or Transpose Solution to plot line chart

I have the following structure in a table:

NameMetricJuly 2025August 2025Sept 2025Oct 2025Nov 2025Dec 2025Jan 2026

Alpha

Volume0.853040.1459320.5588140.2607460.9274120.9385760.941928
AlphaSurface0.6395940.8452050.5061640.7894470.5120910.1807070.294231

Alpha

Length0.3641180.6548810.2323210.1642250.4341640.5320530.047781

Gamma

Length

0.4637190.5250740.7198420.5317540.8508020.857330.457149

Gamma

Surface0.1022470.5430210.8289110.1489180.4519050.7785380.565927
GammaVolume0.7553310.3970140.3719910.9751350.9056380.9578970.256631
EpsilonLength0.7974440.0798870.163390.4171410.854730.5838540.374728
EpsilonSurface0.2592660.0215440.3671670.1611250.1023620.6757980.317543
EpsilonVolume0.5637340.3480620.7226320.7648140.5266060.2615070.138122
BetaVolume0.0985890.4123910.6372960.7921910.2608990.5100290.925143
BetaSurface0.2071630.146520.4383470.7167660.9480660.0490090.401906
BetaLength0.8370540.939430.0578440.2428150.4734920.5366310.447548

I want to be able to plot line charts for series "Volume", "Surface", "Length" over the time axis (X) as column headers. The slicer is the Name column.

For the life of me, I have tried pivoting, unpivoting, transposing and what not, and can't figure out how to get the table into a proper format for plotting this. Please help. Thanks!

  • Nozama,

     

    Try this solution.

     

    1. In Power Query, select all Month Year columns and unpivot.

     

     

    Rename columns as desired.

     

     

    2. Create measure:

     

    Metric Value = SUM ( 'Table'[Value] )

     

    3. Create visuals:

     

     

2 Replies

  • Nozama,

     

    Try this solution.

     

    1. In Power Query, select all Month Year columns and unpivot.

     

     

    Rename columns as desired.

     

     

    2. Create measure:

     

    Metric Value = SUM ( 'Table'[Value] )

     

    3. Create visuals:

     

     

  • Hi,

    This M code transforms your data as follows

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name", "Metric"}, "Attribute", "Value"),
        #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Metric]), "Metric", "Value"),
        #"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Name", type text}, {"Attribute", type date}, {"Volume", type number}, {"Surface", type number}, {"Length", type number}})
    in
        #"Changed Type"

    Hope this helps.