Forum Discussion

ryan_b_fiting's avatar
ryan_b_fiting
Post Patron
4 years ago

Count values for specific date or date range

Hi Community - 

I am looking to count values on a specific date / date range. 

I have two tables.  Date_Table and Admissions Table that are joined on Date / Admission_Date.

Admissions Table is as follows:

Account NumberAdmission DateDischarge Date
1231/1/20221/3/2022
2341/3/20221/5/2022
3451/4/2022 
4561/1/20221/2/2022
5671/2/20221/4/2022
   

 

I am trying to count how many accounts were active for a specific date or date range.   So for the sample data set above I would expect this output.

Expected Output
DateActive Stays
1/1/2022                  2
1/2/2022                  3
1/3/2022                  3
1/4/2022                  3
1/5/2022                  2
1/6/2022                  1

 

My current measure is not giving me my desired output:

 

Census = 
VAR _MinDate = MIN(Date_Table[Date] )
VAR _MaxDate = MAX(Date_Table[Date] )

RETURN

COUNTROWS(
    FILTER(
        Admits,Admits[Date_of_Admission__c] >= _MinDate &&
        Admits[Date_of_Discharge__c] <= _MaxDate )
)

 

 

Any insight on how to calculate this, or where I am making my mistake in my measure would be appreciated!

Thanks Community!

Ryan F.

8 Replies