Forum Discussion
How to count open cases by selected date without generating all intermediate dates?
- 4 months ago
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 ResultThis 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.
- 4 months ago
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!