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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Calculate percentage based on two different tables

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

IDName   Exam_Date
1David10/12/2020
2Lynn09/11/2020
3Leo01/08/2020
4Luna03/02/2020

 

table: Employees

IDName    Departament
1DavidA
2LynnB
3LeoC
4LunaA
5AlexA
6LisaC

 

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
A66,66 %
B100 %
C50 %

 

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?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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:

v-yangliu-msft_0-1615798747719.png

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.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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:

v-yangliu-msft_0-1615798747719.png

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.

Anonymous
Not applicable

This works. The .pbix is located here.

Capture.JPG

 

 

 

Anonymous
Not applicable

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.

pranit828_8-1615512400764.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors