Forum Discussion

RichOB's avatar
RichOB
Post Partisan
1 year ago
Solved

Day Count Measure

Hi, using the table below, I need the number of days that each Room was empty per month, please:   Location Room Empty_Start_Date Empty_End_Date Days_Empty Edinburgh E1 01/04/2024 24/0...
  • burakkaragoz's avatar
    burakkaragoz
    1 year ago

    If your DaysOpen measure is showing blank in a card, it might be because there's no row context — try wrapping it like this:

    DaysOpen = 
    CALCULATE(
        DATEDIFF(MIN('Table'[Start_Date]), TODAY(), DAY)
    )

    Now for the line graph part — if you want to show how many items are still open per month, you’ll need to:

    1. Create a Calendar table with a full date range.
    2. Create a relationship from Calendar[Date] to Table[Start_Date].
    3. Use a measure like this:
    OpenItems = 
    CALCULATE(
        COUNTROWS('Table'),
        'Table'[Start_Date] <= MAX('Calendar'[Date])
    )

    This will count how many items were open as of each date in the calendar, and you can plot that over time.

    Let me know if you want to include End_Date logic too (like only count items that haven’t been closed yet).
    translation and formatting supported by AI