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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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
Solved! Go to Solution.
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.
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
Thanks for your sugestion
It was almost right, this will do what I want
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.
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
Thanks for your sugestion
It was almost right, this will do what I want
User | Count |
---|---|
15 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
18 | |
13 | |
7 | |
5 |