Forum Discussion

RichOB's avatar
RichOB
Icon for Post Partisan rankPost Partisan
1 year ago
Solved

Need help with Day Count measure between end dates and start dates

Hi, apologies for posting similar to a previous post, but my issue remains. I have student accommodation and under each Property I need to add the Days_Empty column.   1 - Per each bedspace, I need...
  • v-dineshya's avatar
    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