Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi there, I was wondering how to count the number of absent days. Saw a lot of other examples on the community, but I'm not sure if I'm doing it the right way.
I have created a fake dataset which looks like my original model: https://www.dropbox.com/s/0ju70kfu3kxokrm/Sample%20file%20HR%20data.pbix?dl=0
So I have a table with Employees (all rows have an unique EmployeeID) and another table which registers the absent days etc. An employee could be absent due to illness, holiday etc.
What I would like is to have an overview of the amount of absent days per period. So when I slice per week I want to see how many absent days there were in a week, when I slice per month I want to see how many absent days there were in a month and so on...
I think the table 'SickLeave' is fine as it is, I just need to create a measure that count it and ONLY COUNTS when the REASON is "Sick", so Maternity leave etc. should NOT be counted in the measure.
My DAX skills are not that good, therefore I'm asking for some help.
If someone could also know how to count the current active employees, that would be an amazing extra!
Thanks in advance! If one needs more info etc. just shoot your question!
Solved! Go to Solution.
Hi @Gjakova
Count Days = CALCULATE(COUNTROWS(SickLeave),FILTER(SickLeave,SickLeave[Reason] = "Sick"))
Take a look at the pbix file attached below.
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Hi @Gjakova ,
Fill the [EndDate] = Blank() with TODAY()?
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Good suggestion, thanks!
Hi @Gjakova
Count Days = CALCULATE(COUNTROWS(SickLeave),FILTER(SickLeave,SickLeave[Reason] = "Sick"))
Take a look at the pbix file attached below.
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Hi @FrankAT I tried your solution, but I don't understand how you handle the blank enddates? In your example they are left empty and thus not counted(?). Is there a way to fix that? Or should I leave it blank. Since the model is connected with an API, I think the null values automatically get adjusted once new data comes in?
But if they are blank, those people will not be counted, correct?
Something like this should work for you:
Hi @Anonymous thank you for your input, but I think it has to be more complex. An employee has a StartDate when he called in sick and an EndDate when he came to the office again (thus was better). So someone might have called in sick on October 5th and came back to the office at October 16th. So the amount of days he was sick would have been 10 working days.
In Power BI that event is registred as 1 row, so I don't think COUNTROWS is suitable for this.
I basically have to calculate all the days between StartDate and EndDate (EndDate could also be blank) for every row where the reason of absence was "Sick".
Hi @guested Thank you for your response, but unfortunalety it is showing me the same value for every month and every year. I think it is a relationship problem? Do you have any more clue about it? Thanks again!
I can't get to your dataset at the moment but I believe you want a calculate and countrows like this
calculate(countrows('tablename'),SickdayColumnName="Sick")
calculate lets you add many filters and if it needs to be even more complex one of the calculate filters, can be a Filter() function as well.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
73 | |
58 | |
36 | |
32 |
User | Count |
---|---|
90 | |
62 | |
61 | |
49 | |
45 |