Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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% | ||
| A | 100% | 33.33% | |
| Dept1 | Dept2 | Dept3 |
Sample Data:
Table 1:
| Department | Grade | ID |
| Dept1 | A1 | 11 |
| Dept1 | A2 | 12 |
| Dept2 | A1 | 13 |
| Dept2 | B1 | 14 |
| Dept2 | B2 | 15 |
| Dept3 | C1 | 16 |
| Dept3 | D1 | 17 |
| Dept3 | D2 | 18 |
| Dept3 | E1 | 19 |
| Dept3 | C1 | 20 |
| Dept2 | D1 | 21 |
Table 2:
| ID | Active |
| 11 | 1 |
| 12 | 1 |
| 13 | 1 |
| 14 | 1 |
| 15 | 1 |
| 16 | 1 |
| 17 | 1 |
| 18 | 1 |
| 19 | 1 |
| 20 | 0 |
| 21 | 0 |
Solved! Go to 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")
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)
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.
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].
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]))
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:
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")
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)
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.
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.
@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! 🙂
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 35 | |
| 34 | |
| 27 |
| User | Count |
|---|---|
| 136 | |
| 96 | |
| 77 | |
| 67 | |
| 65 |