Forum Discussion
pgd
3 years agoFrequent Visitor
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...
- 3 years ago
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.
v-jianboli-msft
Community Support
3 years agoHi 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.
pgd
3 years agoFrequent Visitor
v-jianboli-msft Thank you very much! This is exactly what I was looking for.