Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Dear community,
In Power Bi i'm faced with the following problem
We work in 3 shifts of 8 hours and i want to know the following
i want to count how many events are open at the start of the shift
i want to count how many events are open during the shift
i want to count how many events are open at the end of the shift
See screenshot
The shift are from 7:00 till 15:00 from 15:00 till 23:00 and from 23:00 till 7:00 the next day
The data set has a start date a time to the minute E.g. 23-11-2024 15:21
And an end date and time to the minute 24-11-2024 07:48
I have created a date table and a time table to the minute of every day.
The count of open events per dag i managed by using a inactive relationship between the date table and the fact table.
i used
But i have no idea how to get this done on shift base a metioned above.
Dear Community,
Find the sample data below.
The goal is to have a count of the number of event per Shift
The 3 shifts are from 7:00 till 15:00 from 15:00 till 23:00 and from 23:00 till 7:00 the next day.
see post above for more details.
Thanks in advance.
| EventID | closed | ClosingDate | closing_time | Start_date | Start_time | CloseDateTime | StartDateTime |
| 140395 | Y | 1-okt-24 | 511 | 1-okt-24 | 411 | 1-10-2024 08:31 | 1-10-2024 06:51 |
| 140398 | Y | 1-okt-24 | 722 | 1-okt-24 | 457 | 1-10-2024 12:02 | 1-10-2024 07:37 |
| 140408 | Y | 2-okt-24 | 846 | 1-okt-24 | 1031 | 2-10-2024 14:06 | 1-10-2024 17:11 |
| 140424 | Y | 2-okt-24 | 501 | 2-okt-24 | 419 | 2-10-2024 08:21 | 2-10-2024 06:59 |
| 140514 | Y | 15-okt-24 | 916 | 4-okt-24 | 1140 | 15-10-2024 15:16 | 4-10-2024 19:00 |
| 140567 | Y | 11-okt-24 | 621 | 8-okt-24 | 426 | 11-10-2024 10:21 | 8-10-2024 07:06 |
| 140578 | Y | 9-okt-24 | 885 | 8-okt-24 | 1081 | 9-10-2024 14:45 | 8-10-2024 18:01 |
| 140604 | Y | 10-okt-24 | 374 | 9-okt-24 | 1073 | 10-10-2024 06:14 | 9-10-2024 17:53 |
| 140615 | Y | 10-okt-24 | 855 | 10-okt-24 | 478 | 10-10-2024 14:15 | 10-10-2024 07:58 |
| 140631 | Y | 11-okt-24 | 455 | 11-okt-24 | 289 | 11-10-2024 07:35 | 11-10-2024 04:49 |
| 140635 | Y | 11-okt-24 | 616 | 11-okt-24 | 448 | 11-10-2024 10:16 | 11-10-2024 07:28 |
| 140636 | Y | 12-okt-24 | 466 | 11-okt-24 | 467 | 12-10-2024 07:46 | 11-10-2024 07:47 |
| 140642 | Y | 12-okt-24 | 412 | 11-okt-24 | 710 | 12-10-2024 06:52 | 11-10-2024 11:50 |
| 140646 | Y | 11-okt-24 | 1187 | 11-okt-24 | 849 | 11-10-2024 19:47 | 11-10-2024 14:09 |
| 140634 | Y | 13-okt-24 | 693 | 11-okt-24 | 1080 | 13-10-2024 11:33 | 11-10-2024 18:00 |
| 140662 | Y | 12-okt-24 | 465 | 12-okt-24 | 355 | 12-10-2024 07:45 | 12-10-2024 05:55 |
| 140676 | Y | 14-okt-24 | 1034 | 13-okt-24 | 366 | 14-10-2024 17:14 | 13-10-2024 06:06 |
| 140684 | Y | 14-okt-24 | 700 | 13-okt-24 | 477 | 14-10-2024 11:40 | 13-10-2024 07:57 |
| 140686 | Y | 15-okt-24 | 1266 | 13-okt-24 | 616 | 15-10-2024 21:06 | 13-10-2024 10:16 |
| 140694 | Y | 14-okt-24 | 1172 | 14-okt-24 | 262 | 14-10-2024 19:32 | 14-10-2024 04:22 |
| 140695 | Y | 19-okt-24 | 695 | 14-okt-24 | 328 | 19-10-2024 11:35 | 14-10-2024 05:28 |
| 140705 | Y | 14-okt-24 | 992 | 14-okt-24 | 716 | 14-10-2024 16:32 | 14-10-2024 11:56 |
| 140717 | Y | 15-okt-24 | 459 | 15-okt-24 | 223 | 15-10-2024 07:39 | 15-10-2024 03:43 |
| 140725 | Y | 16-okt-24 | 312 | 15-okt-24 | 722 | 16-10-2024 05:12 | 15-10-2024 12:02 |
| 140729 | Y | 16-okt-24 | 312 | 15-okt-24 | 1088 | 16-10-2024 05:12 | 15-10-2024 18:08 |
| 140731 | Y | 16-okt-24 | 234 | 15-okt-24 | 1104 | 16-10-2024 03:54 | 15-10-2024 18:24 |
| 140759 | Y | 19-okt-24 | 178 | 16-okt-24 | 998 | 19-10-2024 02:58 | 16-10-2024 16:38 |
| 140761 | Y | 17-okt-24 | 54 | 16-okt-24 | 1070 | 17-10-2024 00:54 | 16-10-2024 17:50 |
| 140770 | Y | 17-okt-24 | 168 | 16-okt-24 | 1369 | 17-10-2024 02:48 | 16-10-2024 22:49 |
| 140772 | Y | 17-okt-24 | 1042 | 17-okt-24 | 312 | 17-10-2024 17:22 | 17-10-2024 05:12 |
| 140780 | Y | 19-okt-24 | 758 | 17-okt-24 | 636 | 19-10-2024 12:38 | 17-10-2024 10:36 |
| 140785 | Y | 17-okt-24 | 1230 | 17-okt-24 | 1145 | 17-10-2024 20:30 | 17-10-2024 19:05 |
| 140790 | Y | 19-okt-24 | 840 | 18-okt-24 | 331 | 19-10-2024 14:00 | 18-10-2024 05:31 |
| 140795 | Y | 18-okt-24 | 787 | 18-okt-24 | 754 | 18-10-2024 13:07 | 18-10-2024 12:34 |
| 140808 | Y | 19-okt-24 | 1103 | 19-okt-24 | 721 | 19-10-2024 18:23 | 19-10-2024 12:01 |
| 140811 | Y | 19-okt-24 | 1177 | 19-okt-24 | 1095 | 19-10-2024 19:37 | 19-10-2024 18:15 |
This is basic timeslot matching (you mentioned minute level granularity so you will see 1440 a lot).
Performance is not great in DAX, could be done in Power Query as well since the data is immutable.
Caution: There may be double counting since your shift time periods overlap.
See attached.
Dear lbendlin,
Thank you for the suggestion but the Power Bi performance is very good even with this small data set.
The real data has 10k+ rows therefore this will not be a great solution.
Also the double counting is not great.
How can Power Query help?
To avoid the double counting remove the interval overlaps as I showed in my example.
A shift ends one minute before the next one starts.
For the performance issue you could choose to implement a two step validation. Once for the date range, and then only if that matches, the second one for the minute range. That way you can avoid most of the delay.
open during v2 =
VAR md =
MAX ( 'Calendar'[Date] )
VAR a =
CROSSJOIN (
FILTER ( Events, md IN CALENDAR ( [Start_date], [ClosingDate] ) ),
Shifts
)
VAR b =
ADDCOLUMNS (
a,
"matches",
IF (
COUNTROWS (
INTERSECT (
GENERATESERIES ( [StartDateTime] * 1440, [CloseDateTime] * 1440 ),
GENERATESERIES ( md * 1440 + [Start], md * 1440 + [End] )
)
) > 0,
1,
0
)
)
VAR c =
SUMX ( b, [matches] )
RETURN
IF ( c > 0, c )
This performs much better but sacrifices the date totals.
The real data has 10k+ rows
Please provide sample data that fully covers your issue.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!