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
kodnil2020
Helper I
Helper I

Create Clustered column Chart

Hello, 

 

I am new to Power BI and still needs to learn few things. Appreciate your help here. 

I have 2 tables:

Table 1:  Employee Grades with Department

Table 2:  Active/Inactive employees

 

Ask: Create Clustered coumn chart of Active employees

 

D & Above  75%
C  25%
B 66.66% 
A100%33.33% 
 Dept1Dept2Dept3

 

Sample Data:

Table 1: 

DepartmentGradeID
Dept1A111
Dept1A212
Dept2A113
Dept2B114
Dept2B215
Dept3C116
Dept3D117
Dept3D218
Dept3E119
Dept3C120
Dept2D121

 

Table 2:  

IDActive
111
121
131
141
151
161
171
181
191
200
210
1 ACCEPTED SOLUTION

Hi @kodnil2020 ,

 

We can create a column and a matrix table to meet your requirement.

 

1. Create a calculate column to sort Grade.

 

Legend = 
SWITCH(
    TRUE(),
    CONTAINSSTRING('Table 1'[Grade],"A"),"A",
    CONTAINSSTRING('Table 1'[Grade],"B"),"B",
    CONTAINSSTRING('Table 1'[Grade],"C"),"C","D & Above")

 

Crea1.jpg

 

Then we can create a measure and put the column to legend in Clustered Column Chart.

 

Measure = 
var _x = CALCULATE(DISTINCTCOUNT('Table 1'[ID]),FILTER('Table 2','Table 2'[Active]=1))
var _y = CALCULATE(DISTINCTCOUNT('Table 1'[ID]),FILTER(ALLSELECTED('Table 2'),'Table 2'[Active]=1),FILTER(ALLSELECTED('Table 1'),'Table 1'[Department]=MAX('Table 1'[Department])))
return
DIVIDE(_x,_y)

 

crea2.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

6 REPLIES 6
v-zhenbw-msft
Community Support
Community Support

Hi @kodnil2020 ,

 

We can use the following steps to meet your requirement.

 

1. We assume that the two tables have a relationship based on [ID].

 

C1.jpg

 

2. Then we can create a measure.

 

active person count = CALCULATE(DISTINCTCOUNT('Table 2'[ID]),FILTER('Table 2','Table 2'[Active]=1))

 

Or this measure is also right.

 

active sum = CALCULATE(SUM('Table 2'[Active]))

 

C2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Yes. 2 tables are connected.

This is what i am looking for:

For all departments show clustered chart:

1. X axis: departments

2. Y Axis: percentage of Active Grades

 

Group all "A" grades and find percentage based on active employees

Group all "B" grades and find percentage based on active employees

Group all "C" grades and find percentage based on active employees 

Group all "D & Above" grades and find percentage based on active employees

 

Sample graph & percentage calculation below:

 
 
 
 

Capture.PNG

 

Hi @kodnil2020 ,

 

We can create a column and a matrix table to meet your requirement.

 

1. Create a calculate column to sort Grade.

 

Legend = 
SWITCH(
    TRUE(),
    CONTAINSSTRING('Table 1'[Grade],"A"),"A",
    CONTAINSSTRING('Table 1'[Grade],"B"),"B",
    CONTAINSSTRING('Table 1'[Grade],"C"),"C","D & Above")

 

Crea1.jpg

 

Then we can create a measure and put the column to legend in Clustered Column Chart.

 

Measure = 
var _x = CALCULATE(DISTINCTCOUNT('Table 1'[ID]),FILTER('Table 2','Table 2'[Active]=1))
var _y = CALCULATE(DISTINCTCOUNT('Table 1'[ID]),FILTER(ALLSELECTED('Table 2'),'Table 2'[Active]=1),FILTER(ALLSELECTED('Table 1'),'Table 1'[Department]=MAX('Table 1'[Department])))
return
DIVIDE(_x,_y)

 

crea2.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

I am getting below error:

"DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values."

 

In your screen shot there are 4 filters {}, dept, legend, measure. Which one is first filter?

Hi @kodnil2020 ,

 

Please check what type of field Table 2[active] is. Please change the active column to Whole number type and try again.

 

Create1.jpg

 

Best regards,

 

Community Support Team _ zhenbw

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

Greg_Deckler
Community Champion
Community Champion

@kodnil2020 - Assuming that your tables are related on ID, you should just have to add Active column to your Filters pane and set it to 1.

 

And, welcome to the community. Check out this article here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 

And you did really well on that front! 🙂



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.