Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Claus_Vad
Frequent Visitor

Need to calculate number of active cases at any date

Hi there
I need to calculate number of active cases at any date, and show them in a line chart

Have a fact table with around 2,500,000 records/cases, dates mostly opening days monday - friday, but want to show for all days

Every case has a start date and a end date (if the case is closed)

Any sugestions?

Regards Claus

2 ACCEPTED SOLUTIONS
v-cazheng-msft
Community Support
Community Support

Hi @Claus_Vad,

 

You need a calendar table firstly, and you could create it by a Calculated table.

Calendar =
VAR minDate =
    MIN ( 'Fact Table'[start date] )
VAR maxDate =
    TODAY ()
RETURN
    CALENDAR ( minDate, maxDate )

 

Then, you need a Measure to count cases.

Active Case Number =
VAR num =
    CALCULATE (
        COUNT ( 'Fact Table'[case] ),
        FILTER (
            'Fact Table',
            'Fact Table'[start date] <= MAX ( 'Calendar'[Date] )
                && ISBLANK ( 'Fact Table'[end date] )
        )
    )
RETURN
    IF ( ISBLANK ( num ), 0, num )

 

The result looks like this.

vcazhengmsft_0-1659063727193.png

 

Also, attached the pbix file.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,                                             

Community Support Team _ Caiyun

View solution in original post

Hi @v-cazheng-msft 

Thanks for your sugestion 

It was almost right, this will do what I want 

Active Case Number =
VAR num =
CALCULATE (
COUNT ( 'Fact Table'[case] ),
FILTER (
'Fact Table',
'Fact Table'[start date] <= MAX ( 'Calendar'[Date] )
&& ('Fact Table'[end date] > min('Calendar'[Date])
|| ISBLANK ( 'Fact Table'[end date] ))
)
)
RETURN
IF ( ISBLANK ( num ), 0, num )

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Claus_Vad 
Please define your business logic of "active cases". Thank you

Claus_Vad
Frequent Visitor

Hi @tamerj1

a case is active when it have a startdate and enddate is blank

v-cazheng-msft
Community Support
Community Support

Hi @Claus_Vad,

 

You need a calendar table firstly, and you could create it by a Calculated table.

Calendar =
VAR minDate =
    MIN ( 'Fact Table'[start date] )
VAR maxDate =
    TODAY ()
RETURN
    CALENDAR ( minDate, maxDate )

 

Then, you need a Measure to count cases.

Active Case Number =
VAR num =
    CALCULATE (
        COUNT ( 'Fact Table'[case] ),
        FILTER (
            'Fact Table',
            'Fact Table'[start date] <= MAX ( 'Calendar'[Date] )
                && ISBLANK ( 'Fact Table'[end date] )
        )
    )
RETURN
    IF ( ISBLANK ( num ), 0, num )

 

The result looks like this.

vcazhengmsft_0-1659063727193.png

 

Also, attached the pbix file.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,                                             

Community Support Team _ Caiyun

Hi @v-cazheng-msft 

Thanks for your sugestion 

It was almost right, this will do what I want 

Active Case Number =
VAR num =
CALCULATE (
COUNT ( 'Fact Table'[case] ),
FILTER (
'Fact Table',
'Fact Table'[start date] <= MAX ( 'Calendar'[Date] )
&& ('Fact Table'[end date] > min('Calendar'[Date])
|| ISBLANK ( 'Fact Table'[end date] ))
)
)
RETURN
IF ( ISBLANK ( num ), 0, num )

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (25)