Forum Discussion

pgd's avatar
pgd
Frequent Visitor
3 years ago
Solved

How to create clustered column chart with different legend?

I have tabular excel data. I have wage rate (20, 25, 30, 35, and 40) in one column and <1, <2, <3, >=3 as columns. The wage rate repeats per division code. So division 1 has 20, 25, 30, 35, and 40 in cells 1-5. Division code 2 has 20, 25, 30, 35, and 40 in cells 6-10, etc. Please see below for reference. 

 

 

How do I plot the costs (<1, <2, <3, >=3) on the x axis where the legend corresponds to the wage rate (20, 25, 30, 35, 40)?

 

I want it to look the graph below. Instead of Central, South, East, and West, I'm trying to do <1, <2, <3, and >=3. Instead of furniture, office supplies, and technology, I'm trying to do the wage rates. 

Do you know how I can do this? For some reason, I haven't been able to add wage to the legend field. 

  • Hi pgd ,

     

    Please try:

    Unpivot columns:

    Here is the M code:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY6xEcAwCAN3ce0iYAzxLLnsv0aQLsGXRoUeCV1X06P1JpA5U0xShsFrd08MUxUSwAM4Cg8Gcc7Dk7I2Zppt6F2eErvcmIYp1cuK9zdwwFxScqJxT5t4pqsqtDCnOdIOU+Kf5jTnIIgjbbMwp5l9ewNBeonvBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Wage Rate" = _t, #"<1" = _t, #"<2" = _t, #"<3" = _t, #">=3" = _t, Division = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Wage Rate", Int64.Type}, {"<1", Int64.Type}, {"<2", Int64.Type}, {"<3", Int64.Type}, {">=3", Int64.Type}, {"Division", Int64.Type}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Wage Rate", "Division"}, "Attribute", "Value")
    in
        #"Unpivoted Columns"

     

    Then creaete the visual:

    Final output:

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Hi pgd ,

     

    Please try:

    Unpivot columns:

    Here is the M code:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY6xEcAwCAN3ce0iYAzxLLnsv0aQLsGXRoUeCV1X06P1JpA5U0xShsFrd08MUxUSwAM4Cg8Gcc7Dk7I2Zppt6F2eErvcmIYp1cuK9zdwwFxScqJxT5t4pqsqtDCnOdIOU+Kf5jTnIIgjbbMwp5l9ewNBeonvBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Wage Rate" = _t, #"<1" = _t, #"<2" = _t, #"<3" = _t, #">=3" = _t, Division = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Wage Rate", Int64.Type}, {"<1", Int64.Type}, {"<2", Int64.Type}, {"<3", Int64.Type}, {">=3", Int64.Type}, {"Division", Int64.Type}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Wage Rate", "Division"}, "Attribute", "Value")
    in
        #"Unpivoted Columns"

     

    Then creaete the visual:

    Final output:

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.