This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi everyone,
Not sure how to approch this in powerbi.
I have a table with people and all there vacation, sick days, formation, etc..
Let say i want to count/sum (?) all the time a person was in sick leave, i can see how to count all value, but i would only want the last consecutive date that person was in sick leave, for the exemple :
Adel was on sickleave for 4 consecutive days from 16/02/2023 - 19/02/2023 and also for 3 consecutive days from 21/03/2023 - 23/03/2023.
But i only have an interset to see last group of days she was on sick leave.
The end result should be something like that :
Another exemple for Bastien :
He was in sick leave several time but i only need too see when was the last time and for how long.
Im hope im clear enough in the exemple.
I attach the test model for some clarity.
https://drive.google.com/file/d/1XxzyYgdei3UuisDEqjPZ8aaJzKHFOpen/view?usp=drive_link
Thank you for your support !
Solved! Go to Solution.
Hi @Nomad ,
Try the following:
Consecutive Days =
VAR temptable =
FILTER (
ESTIMATED_DAILY_ABSENCE,
ESTIMATED_DAILY_ABSENCE[DATE]< EARLIER ( ESTIMATED_DAILY_ABSENCE[DATE] )
&& ESTIMATED_DAILY_ABSENCE[FIRST_NAME]
= EARLIER ( ESTIMATED_DAILY_ABSENCE[FIRST_NAME] )
)
RETURN
DATEDIFF (
MAXX ( temptable, ESTIMATED_DAILY_ABSENCE[DATE] ),
ESTIMATED_DAILY_ABSENCE[DATE],
DAY
)
This will return the number of days from last sick leave
Now add this measures:
last day of sick =
VAR temptable =
FILTER (
ESTIMATED_DAILY_ABSENCE,
ESTIMATED_DAILY_ABSENCE[Consecutive Days] > 1
)
VAR datetop =
MAXX ( temptable, ESTIMATED_DAILY_ABSENCE[DATE] )
RETURN
MAXX (
FILTER ( ESTIMATED_DAILY_ABSENCE, ESTIMATED_DAILY_ABSENCE[DATE] >= datetop ),
ESTIMATED_DAILY_ABSENCE[DATE]
)
Number of days =
VAR temptable =
FILTER (
ESTIMATED_DAILY_ABSENCE,
ESTIMATED_DAILY_ABSENCE[Consecutive Days] > 1
)
VAR datetop =
MAXX ( temptable, ESTIMATED_DAILY_ABSENCE[DATE] )
RETURN
COUNTROWS (
FILTER ( ESTIMATED_DAILY_ABSENCE, ESTIMATED_DAILY_ABSENCE[DATE] >= datetop )
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Nomad ,
Try the following:
Consecutive Days =
VAR temptable =
FILTER (
ESTIMATED_DAILY_ABSENCE,
ESTIMATED_DAILY_ABSENCE[DATE]< EARLIER ( ESTIMATED_DAILY_ABSENCE[DATE] )
&& ESTIMATED_DAILY_ABSENCE[FIRST_NAME]
= EARLIER ( ESTIMATED_DAILY_ABSENCE[FIRST_NAME] )
)
RETURN
DATEDIFF (
MAXX ( temptable, ESTIMATED_DAILY_ABSENCE[DATE] ),
ESTIMATED_DAILY_ABSENCE[DATE],
DAY
)
This will return the number of days from last sick leave
Now add this measures:
last day of sick =
VAR temptable =
FILTER (
ESTIMATED_DAILY_ABSENCE,
ESTIMATED_DAILY_ABSENCE[Consecutive Days] > 1
)
VAR datetop =
MAXX ( temptable, ESTIMATED_DAILY_ABSENCE[DATE] )
RETURN
MAXX (
FILTER ( ESTIMATED_DAILY_ABSENCE, ESTIMATED_DAILY_ABSENCE[DATE] >= datetop ),
ESTIMATED_DAILY_ABSENCE[DATE]
)
Number of days =
VAR temptable =
FILTER (
ESTIMATED_DAILY_ABSENCE,
ESTIMATED_DAILY_ABSENCE[Consecutive Days] > 1
)
VAR datetop =
MAXX ( temptable, ESTIMATED_DAILY_ABSENCE[DATE] )
RETURN
COUNTROWS (
FILTER ( ESTIMATED_DAILY_ABSENCE, ESTIMATED_DAILY_ABSENCE[DATE] >= datetop )
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Nomad ,
Please make your link public.
oh right, my bad, done!
So I took the liberty to just based the proposed solution on your first screenshot. This makes use of several helper columns and scanning of the table several times. Please see attached pbix for the details.
Amazing, thanks!
There is also a way to only display the last "latest sick leave", and not there previuous one ?
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 23 | |
| 22 | |
| 16 | |
| 15 |
| User | Count |
|---|---|
| 60 | |
| 35 | |
| 28 | |
| 22 | |
| 21 |