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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Calculate the percentage of abscens

Hello! I would like some help with dax. I need to calculate the percentage that is absent. For this I have a table that stores people who have been absent from work:

DatePerson IDCode for cause of absenceCode for organisation Period
2021-09-01123A1200202109
2021-09-01345A1350202109
2021-09-01678B1250202109
And so onAnd so onAnd so onAnd so onAnd so on

 

I also have a table with all employees:

 

PeriodPersonIDCode for organisation 
2021091231200
2021093451350
2021096781250

 

I made a measure that calculates how many are absent, and it looks like this: number absent =DISTINCTCOUNT('table_absence'[PersonID]).

 

I also have a measure that counts all employees. 

 

Now I want a measure that calculate the percentage that is absent per day, but the problem is that first table is per day and the other one is per month. 

 

I tried with this but it does not work: 

absence per day (%) = CALCULATE(DIVIDE([number absent];[All_Employees])* 100;employees[period] = SELECTEDVALUE('table_absence'[period]))
 
For example, 2021-09-01 there were 450 people away, and that month had 5000 employees, so I want it to take 450 / 5000 * 100 
 
Another problem is that we can only see the number of employees the month after, so if I look at how many are away today, the number of employees would be empty. I would like a IF statements that checks if it is the current month, then take the employees from last month, otherwise take same month. 
 
Help please 🙂

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Please check the following methods.

number absent = DISTINCTCOUNT('table_absence'[Person ID])
absence per day (%) = 
CALCULATE(DIVIDE([number absent],COUNT(employees[PersonID])),FILTER(ALL(employees),[Period]=SELECTEDVALUE(employees[Period])))

vzhangti_0-1645688087927.png

Regarding your other question, you need to provide a little more example data, which I fail to understand at the moment. You can be informed of the output you expect.

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Please check the following methods.

number absent = DISTINCTCOUNT('table_absence'[Person ID])
absence per day (%) = 
CALCULATE(DIVIDE([number absent],COUNT(employees[PersonID])),FILTER(ALL(employees),[Period]=SELECTEDVALUE(employees[Period])))

vzhangti_0-1645688087927.png

Regarding your other question, you need to provide a little more example data, which I fail to understand at the moment. You can be informed of the output you expect.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.