Please can I request some assistance in understanding my measure and why it is not working. I think the problem is the blank rows and it might be related to “row context”
Here is the scenario of what I am trying to resolve:
Patients are discharged from hospital with a reablement service and this service does end. The report is complied daily and therefore there will always be patients who are not yet discharged from the service.
So what I want to measure is the Length of Stay (LOS) in the reablement service. There are two key dates involved and the discharge date can be blank:
- Reablement Start Date
- HART discharge Date
- Blank discharge date (patient not yet discharged)
LOS2 is the first measure that I developed which checks if the “discharge date” is BLANK and if it is the measure returns a 0 else the measure subtracts the reablement start date from the discharge date. This measure works fine and is halfway to solving the problem.
Measure LOS2
SUMX (
tbl_Data_Master_HART,
IF (
tbl_Data_Master_HART[HART discharge Date] = BLANK (),
0,
DATEDIFF (
tbl_Data_Master_HART[Reablement Start Date],
tbl_Data_Master_HART[HART discharge Date],
DAY
) + 1
)
)
Below is what the measure returns
When a patient is not yet discharged a 0 is no use, I need to know how long they have they been in the service so I need to use Today’s date and subtract the reablement start date
However, I get stuck when I try and replace the 0 in the logical statement with this calculation
DATEDIFF (
tbl_Data_Master_HART[Reablement Start Date],
TODAY(),
DAY
) + 1,
It doesn’t work and I suspect the problem may be related to the row context or the blanks
The full formula is:
SUMX (
tbl_Data_Master_HART,
IF (
tbl_Data_Master_HART[HART discharge Date] = BLANK (),
DATEDIFF (
tbl_Data_Master_HART[Reablement Start Date],
TODAY(),
DAY
) + 1,
DATEDIFF (
tbl_Data_Master_HART[Reablement Start Date],
tbl_Data_Master_HART[HART discharge Date],
DAY
) + 1
)
)
There are no errors in the formula checker and in the DAX Formatter does not report any bugs yet when I add the measure to the pivot table I get the following error message