Forum Discussion
Need help with Day Count measure between end dates and start dates
- 1 year ago
Hi RichOB ,
Thanks for reaching out to the Microsoft fabric community forum.
Create a Calculated Column
You can use the following DAX expression for your Days_Empty calculated column:Days_Empty =
VAR CurrentBedspace = 'Tenancies'[Bedspace_Number]
VAR CurrentEndDate = 'Tenancies'[End_Date]
VAR CurrentStartDate = 'Tenancies'[Start_Date]
VAR NextStartDate =
CALCULATE(
MIN('Tenancies'[Start_Date]),
FILTER(
'Tenancies',
'Tenancies'[Bedspace_Number] = CurrentBedspace &&
'Tenancies'[Start_Date] > CurrentStartDate
)
)RETURN
IF(
ISBLANK(CurrentEndDate),
0,
IF(
ISBLANK(NextStartDate),
DATEDIFF(CurrentEndDate, TODAY(), DAY),
MAX(0, DATEDIFF(CurrentEndDate, NextStartDate, DAY))
)
)If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards
Did you add this as a calculated column on your table? It is not meant to be a measure.