Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello,
I have two tables, one that shows all the people who did the annual medical examination required by the company (table Medical_Exams), and other that has the total number of employees in the company (table Employees). They follow this structure:
table: Medical_Exams
ID | Name | Exam_Date |
1 | David | 10/12/2020 |
2 | Lynn | 09/11/2020 |
3 | Leo | 01/08/2020 |
4 | Luna | 03/02/2020 |
table: Employees
ID | Name | Departament |
1 | David | A |
2 | Lynn | B |
3 | Leo | C |
4 | Luna | A |
5 | Alex | A |
6 | Lisa | C |
I want to make a simple percentage of all the people who already have done their medical exams and show it in a table view in my dashboard, separated by department.
The end result in my dashboard should be a table like this:
Departament | Percentage |
A | 66,66 % |
B | 100 % |
C | 50 % |
I've already created a calculated column in the "Medical_Exams" table that uses a LookUpValue to get the person's department based on the ID column, but I can't create a measure that does this percentage calculation based on two tables.
Can someone help me?
Solved! Go to Solution.
Hi @Anonymous ,
Here are the steps you can follow:
1. Create measure.
Percentage =
var _1=CALCULATE(COUNT('Employees'[ID]),FILTER(ALL('Employees'),'Employees'[ Departament]=MAX('Employees'[ Departament])))
var _2=COUNTX(FILTER('Employees',[Name] in SELECTCOLUMNS('Medical_Exams',"1",[Name])),[ID])
return
DIVIDE(_2,_1)
2. Result:
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Here are the steps you can follow:
1. Create measure.
Percentage =
var _1=CALCULATE(COUNT('Employees'[ID]),FILTER(ALL('Employees'),'Employees'[ Departament]=MAX('Employees'[ Departament])))
var _2=COUNTX(FILTER('Employees',[Name] in SELECTCOLUMNS('Medical_Exams',"1",[Name])),[ID])
return
DIVIDE(_2,_1)
2. Result:
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
You should create a relationship between both the tables on ID column.
Also, IF you already have a column for dept created then use the below measure.
_pcnt =
DIVIDE(CALCULATE(COUNT(Medical_Exams[id]),ALLEXCEPT(Medical_Exams, Medical_Exams[Departament])),
CALCULATE(COUNT(Employees[id]),ALLEXCEPT(Employees, Employees[Departament])),0)
Once this measure is created click on the measure name and change the format to percentage and give 2 decimal precision.
Hope it resolves your issue? Did I answer your question? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!! Linkedin Profile |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
71 | |
68 | |
50 | |
30 |
User | Count |
---|---|
119 | |
101 | |
73 | |
65 | |
40 |