Updated Problem: I'm trying to calculate the daily population of patients at our center for any given date using the patient's booking date (start date) and their release date -- using DAX and Power Pivot. I'm planning on using it in PowerBI.
I'm using two tables: 1) a main table with the patient data containing columns for booking date, release date, gender, provider, and race and 2) a date table (calendar) and have established a relationship between the two tables. The date table is date dimension.
Based on recommendations for my initial question, I created a calculated column in the calendar table using formula below.
PatientCount :=
SUMX (
Patients,
IF (
Patients[Booking Date] <= 'Calendar'[Date]
&& Patients[Release Date] >= 'Calendar'[Date],
1,
0
)
)
I then created an aggregate measure to compute the average daily population. This works; however, using this method I cannot figure out how to slice it by the patient table columns (e.g. gender, provider, race) since the calculated column is in the calendar table.