Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Add multiple columns as X axis in stack column chart

Hi All.

 

I have a requirement something similar to below:

 

Data:

 

Emp                 Group 1            Group 2          Group 3

AGroup 1  
B Group 2 
CGroup 1  
D Group 2 
E  Group 3
FGroup 1  

 

I need to show this data in line and stacked column chart with X Axis as group 1, group 2, group 3 and Y axis as count against each group.

 

Thanks in advance

 

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please check the following step as below.

 

1. Unpivot the table in power query. Please check the M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXIvyi8tUDAEskAoVidayQnChkgYwUSdsap1warWFaoCJmEMFnXDNCEWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Emp = _t, #"Group 1" = _t, #"Group 2" = _t, #"Group 3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Emp", type text}, {"Group 1", type text}, {"Group 2", type text}, {"Group 3", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Attribute] <> "Emp"))
in
    #"Filtered Rows"

Capture.PNG

 

2. Then create a measure as below and add it to the line chart to get the result as we need.

 

Measure = CALCULATE(COUNTROWS('Table1 (2)'),FILTER('Table1 (2)','Table1 (2)'[Value]<>BLANK()))

2.PNG

 

Please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please check the following step as below.

 

1. Unpivot the table in power query. Please check the M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXIvyi8tUDAEskAoVidayQnChkgYwUSdsap1warWFaoCJmEMFnXDNCEWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Emp = _t, #"Group 1" = _t, #"Group 2" = _t, #"Group 3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Emp", type text}, {"Group 1", type text}, {"Group 2", type text}, {"Group 3", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Attribute] <> "Emp"))
in
    #"Filtered Rows"

Capture.PNG

 

2. Then create a measure as below and add it to the line chart to get the result as we need.

 

Measure = CALCULATE(COUNTROWS('Table1 (2)'),FILTER('Table1 (2)','Table1 (2)'[Value]<>BLANK()))

2.PNG

 

Please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thanks a lot Frank. This really helpedSmiley Happy

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.