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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jharris32
Frequent Visitor

Calculating active cases by month

Hi! I have a data source that provides open and close date for cases. I need to be able to create a visual that shows how many ACTIVE cases were open in a month (so not only cases that opened that month, but anything that doesn't have a close date yet, and excluding anything that closed in a prior month). 

 

I have a calendar table and then my data source looks something like this:

Case IDOpen DateClose Date
a12/5/202312/05/2023
b10/27/2023 
c5/16/202301/17/2024
d05/06/2021 
x01/16/202110/02/2023
y09/29/202210/24/2023
z07/26/2022

12/13/2023

 

The results should look something like this: 

October 20236
November 20234
December 20235

 

This is the forumula for the measure I tried and it gets me close but I'm still off by a few cases each month:

Open Cases =
VAR SelectedYear = SELECTEDVALUE('Calendar'[Year])
VAR MaxCDate = IF(ISBLANK(SelectedYear)||SelectedYear=YEAR(TODAY()),EOMONTH(TODAY(),0),MAX('Calendar'[Date]))
VAR X = CALCULATE([Handled Cases],
FILTER(ALL('Calendar'),
'Calendar'[Date]<=MAX('Calendar'[Date])
&&
MAX('Calendar'[Date])<=MaxCDate
),
'GAL Docket_Power BI'[Open Date]<=MaxCDate&&'GAL Docket_Power BI'[Close Date]>MaxCDate||ISBLANK('GAL Docket_Power BI'[Close Date])=TRUE())

RETURN X
 
 
Any thoughts on where I'm messing up??

 

 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@jharris32 

pls try this

 

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Open Date]<=max('Table 2'[Date])&&('Table'[Close Date]>=min('Table 2'[Date])||ISBLANK('Table'[Close Date]))))
11.png
pls see the attachment below
 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ryan_mayu
Super User
Super User

@jharris32 

pls try this

 

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Open Date]<=max('Table 2'[Date])&&('Table'[Close Date]>=min('Table 2'[Date])||ISBLANK('Table'[Close Date]))))
11.png
pls see the attachment below
 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.