Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
I’m trying to build a Power BI dashboard that shows how many cases were open on any given day/week, without generating a full list of dates between the Open Date and Close Date for every case.
Right now, I generate all dates between:
This works, but the dataset becomes very large and refresh/update times are very slow.
I want to calculate dynamically which cases were open on a selected date (or during a selected week) using a measure, instead of creating all intermediate dates.
Example:
| A | 01.04.2025 | 22.05.2025 |
If the report is filtered to:
I’m looking for a scalable solution because the dataset is large and performance is important. Thank you so much for your help
| Case | open Date | Close Date |
| 0000463681 | 02.12.2016 | 08.05.2026 |
| 0000463687 | 02.12.2016 | 08.05.2026 |
| 0000572557 | 16.12.2016 | 08.05.2026 |
| 0000572558 | 16.12.2016 | 08.05.2026 |
| 0000574630 | 19.12.2016 | 08.05.2026 |
| 0000575372 | 19.12.2016 | 08.05.2026 |
| 0000647478 | 22.12.2016 | 08.05.2026 |
| 0000661133 | 30.12.2016 | 08.05.2026 |
| 0000825124 | 30.01.2017 | 08.05.2026 |
| 0001047913 | 06.03.2017 | 08.05.2026 |
| 0001132024 | 28.03.2017 | 08.05.2026 |
| 0001140763 | 07.04.2017 | 08.05.2026 |
| 0001399807 | 07.06.2017 | 08.05.2026 |
| 0001522944 | 17.07.2017 | 08.05.2026 |
| 0001522945 | 17.07.2017 | 08.05.2026 |
| 0001857045 | 10.10.2017 | 08.05.2026 |
| 0001857047 | 10.10.2017 | 08.05.2026 |
| 0001857147 | 24.10.2017 | 08.05.2026 |
| 0001857168 | 26.10.2017 | 08.05.2026 |
| 0001857170 | 26.10.2017 | 08.05.2026 |
| 0001857359 | 09.11.2017 | 08.05.2026 |
| 0001913407 | 24.11.2017 | 08.05.2026 |
| 0001971450 | 28.11.2017 | 08.05.2026 |
| 0001984037 | 30.11.2017 | 08.05.2026 |
| 0001985836 | 06.12.2017 | 08.05.2026 |
| 0002003063 | 13.12.2017 | 08.05.2026 |
| 0002109739 | 18.12.2017 | 08.05.2026 |
| 0002109953 | 18.12.2017 | 08.05.2026 |
| 0002146521 | 22.12.2017 | 08.05.2026 |
| 0002154560 | 06.01.2018 | 08.05.2026 |
| 0002290097 | 17.01.2018 | 08.05.2026 |
| 0002292748 | 18.01.2018 | 08.05.2026 |
| 0002303528 | 04.02.2018 | 08.05.2026 |
| 0002307607 | 06.02.2018 | 08.05.2026 |
| 0002620478 | 14.03.2018 | 08.05.2026 |
| 0002642428 | 16.03.2018 | 08.05.2026 |
| 0002642570 | 16.03.2018 | 08.05.2026 |
| 0002680144 | 19.03.2018 | 08.05.2026 |
| 0002695955 | 22.03.2018 | 08.05.2026 |
| 0002866033 | 16.04.2018 | 08.05.2026 |
| 0002944421 | 18.04.2018 | 08.05.2026 |
| 0003094912 | 28.05.2018 | 08.05.2026 |
| 0003094913 | 28.05.2018 | 08.05.2026 |
| 0003244075 | 16.06.2018 | 08.05.2026 |
| 0003254943 | 05.07.2018 | 08.05.2026 |
| 0003254950 | 05.07.2018 | 08.05.2026 |
| 0003254953 | 05.07.2018 | 08.05.2026 |
| 0003254967 | 05.07.2018 | 08.05.2026 |
| 0003254971 | 05.07.2018 | 08.05.2026 |
| 0003254975 | 05.07.2018 | 08.05.2026 |
| 0003254976 | 05.07.2018 | 08.05.2026 |
| 0003254991 | 05.07.2018 | 08.05.2026 |
| 0003255006 | 05.07.2018 | 08.05.2026 |
| 0003255023 | 05.07.2018 | 08.05.2026 |
| 0003255025 | 05.07.2018 | 08.05.2026 |
| 0003256782 | 14.07.2018 | 08.05.2026 |
| 0003256789 | 14.07.2018 | 08.05.2026 |
| 0003256809 | 16.07.2018 | 08.05.2026 |
| 0003256825 | 16.07.2018 | 08.05.2026 |
| 0003256828 | 16.07.2018 | 08.05.2026 |
| 0003256830 | 16.07.2018 | 08.05.2026 |
| 0003256837 | 16.07.2018 | 08.05.2026 |
| 0003256844 | 16.07.2018 | 08.05.2026 |
| 0003256878 | 17.07.2018 | 08.05.2026 |
| 0003256883 | 17.07.2018 | 08.05.2026 |
| 0003256884 | 17.07.2018 | 08.05.2026 |
| 0003256899 | 17.07.2018 | 08.05.2026 |
| 0003256904 | 17.07.2018 | 08.05.2026 |
| 0003256923 | 17.07.2018 | 08.05.2026 |
| 0003256953 | 17.07.2018 | 08.05.2026 |
| 0003256954 | 17.07.2018 | 08.05.2026 |
| 0003256970 | 18.07.2018 | 08.05.2026 |
| 0003265046 | 20.07.2018 | 08.05.2026 |
| 0003265063 | 21.07.2018 | 08.05.2026 |
| 0003375992 | 24.07.2018 | 08.05.2026 |
| 0003396343 | 26.07.2018 | 08.05.2026 |
| 0003396349 | 26.07.2018 | 08.05.2026 |
| 0003396350 | 26.07.2018 | 08.05.2026 |
| 0003396351 | 26.07.2018 | 08.05.2026 |
| 0003396352 | 26.07.2018 | 08.05.2026 |
| 0003396579 | 27.07.2018 | 08.05.2026 |
| 0003396581 | 27.07.2018 | 08.05.2026 |
| 0003396592 | 27.07.2018 | 08.05.2026 |
| 0003396602 | 27.07.2018 | 08.05.2026 |
| 0003396608 | 27.07.2018 | 08.05.2026 |
| 0003396610 | 27.07.2018 | 08.05.2026 |
| 0003396612 | 27.07.2018 | 08.05.2026 |
| 0003396646 | 28.07.2018 | 08.05.2026 |
| 0003396670 | 31.07.2018 | 08.05.2026 |
| 0003432658 | 01.08.2018 | 08.05.2026 |
| 0003432660 | 01.08.2018 | 08.05.2026 |
| 0003432827 | 01.08.2018 | 08.05.2026 |
| 0003446673 | 01.08.2018 | 08.05.2026 |
| 0003446686 | 02.08.2018 | 08.05.2026 |
| 0003451940 | 04.08.2018 | 08.05.2026 |
| 0003452145 | 03.08.2018 | 08.05.2026 |
| 0003452150 | 04.08.2018 | 08.05.2026 |
| 0003452277 | 06.08.2018 | 08.05.2026 |
| 0003452278 | 06.08.2018 | 08.05.2026 |
| 0003452279 | 06.08.2018 | 08.05.2026 |
Solved! Go to Solution.
Make sure there is no relationship between your date table and your cases table, then write a measure like
Num open cases =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( Cases ),
Cases[Open Date] <= MaxDate
&& (
ISBLANK ( Cases[Close Date] ) || Cases[CloseDate] >= MaxDate
)
)
RETURN
Result
This assumes that there is 1 row per case in your Cases table. If that's not the case then you will need to do a DISTINCTCOUNT on Case ID, but that could be significantly slower than a COUNTROWS.
The measure should work at any granularity of date. It counts the number of cases where the open date is on or before the end of the period and the close date is either blank ( presumably still open ) or is on or after the end of the period.
Use no active relationship between the Date table and the Cases table. Then use the following measure:
Open Cases =
VAR _SelectedStart =
MIN ( 'Date'[Date] )
VAR _SelectedEnd =
MAX ( 'Date'[Date] )
RETURN
CALCULATE (
COUNTROWS ( Cases ),
FILTER (
ALL ( Cases ),
Cases[Open Date] <= _SelectedEnd
&& (
ISBLANK ( Cases[Close Date] )
|| Cases[Close Date] >= _SelectedStart
)
)
)
Hi @luzrueda ,
Thank you @cengizhanarslan , @johnt75 for your inputs.
We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.
Thank you.
Thank you for your reminder and support!
Use no active relationship between the Date table and the Cases table. Then use the following measure:
Open Cases =
VAR _SelectedStart =
MIN ( 'Date'[Date] )
VAR _SelectedEnd =
MAX ( 'Date'[Date] )
RETURN
CALCULATE (
COUNTROWS ( Cases ),
FILTER (
ALL ( Cases ),
Cases[Open Date] <= _SelectedEnd
&& (
ISBLANK ( Cases[Close Date] )
|| Cases[Close Date] >= _SelectedStart
)
)
)
Make sure there is no relationship between your date table and your cases table, then write a measure like
Num open cases =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( Cases ),
Cases[Open Date] <= MaxDate
&& (
ISBLANK ( Cases[Close Date] ) || Cases[CloseDate] >= MaxDate
)
)
RETURN
Result
This assumes that there is 1 row per case in your Cases table. If that's not the case then you will need to do a DISTINCTCOUNT on Case ID, but that could be significantly slower than a COUNTROWS.
The measure should work at any granularity of date. It counts the number of cases where the open date is on or before the end of the period and the close date is either blank ( presumably still open ) or is on or after the end of the period.
Thank you so much @johnt75 it was very helpful. I could definitely set this rules for my Dashboard
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |