Forum Discussion
Detailed report drill through on a date for value calculated using two date references (Census data)
Hi everyone,
I have a dataset of patients who visited a hospital, with an admit date and discharge date like so:
| VisitID | AdmitDate | DischargeDate |
| 1 | 1/1/2023 | 2/27/2023 |
| 2 | 1/1/2023 | 1/5/2023 |
| 3 | 1/2/2023 | 1/13/2023 |
| 4 | 1/3/2023 |
|
I have a calendar table with inactive relationships to both the admit and discharge date.
I have a measure within the calendar table to calculate the daily census using this formula:
DailyCensus = CALCULATE(DISTINCTCOUNT(Visits[VisitID]), Visits[AdmitDate] <= MAX(Calendar[Date]) && (Visits[DischargeDate] > MAX(Calendar[Date]) || ISBLANK(Visits[DischargeDate])))
I have another measure to aggregate each daily census as an average using this formula:
AverageDailyCensus = AVERAGEX(Calendar, Calendar[DailyCensus])
I'm visualizing this data on a bar chart, with the date as the axis and average daily census as the values. I used the date hierarchy (year, month, day) which allows drilling down.
From this bar chart, I would like to design a drill through to a detailed page that reports all the patients who were considered in that bar. Using my sample data for example, if I drill through to the bar for January 2, 2023, I should get the following results:
| VisitID | AdmitDate | DischargeDate |
| 1 | 1/1/2023 | 2/27/2023 |
| 2 | 1/1/2023 | 1/5/2023 |
| 3 | 1/2/2023 | 1/13/2023 |
I tried doing it myself and made a page that allows drill through when any of the calendar dateparts in the hierarchy is used as a category. However, the drill through always returns all the visits, no matter what date I drill through.
Any assistance would be greatly appreciated.
Thanks!
1 Reply
- amitchandak
Super User
jdb0912 , We need to use the same measure in the drill table. I have discussed almost similar case here
Power BI Drill Through when Use relationship is used: https://youtu.be/1BM_WGATrQA