Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
RichOB
Post Patron
Post Patron

Day Count Measure

Hi, using the table below, I need the number of days that each Room was empty per month, please:

 

LocationRoomEmpty_Start_DateEmpty_End_DateDays_Empty
EdinburghE101/04/202424/04/202424
EdinburghE201/04/202431/05/202460
GlasgowG101/04/202430/07/2024120
GlasgowG201/04/202401/06/202461


This is the end result I'm looking for :

RoomAprilMayJuneJuly
E124   
E23031  
G1303130 
G23031130
 114933130

**my monthly numbers may be a tad wrong here.

 

Thanks

1 ACCEPTED SOLUTION

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).

View solution in original post

5 REPLIES 5
burakkaragoz
Community Champion
Community Champion

Hi @RichOB ,

 

You can create a measure like this to count the number of days between two dates:

DayCount = DATEDIFF(MIN('Table'[StartDate]), MAX('Table'[EndDate]), DAY)

If you're working with filters or slicers, make sure the context is right — sometimes wrapping it in a CALCULATE or using SELECTEDVALUE helps depending on your setup.

Let me know if you’re trying to count working days or exclude weekends/holidays — that’s a slightly different approach.


If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.

Hi @burakkaragoz thanks for getting back to me, this is great thank you! How would the measure change if there is no end date and I want the current Today's date as the MAX date please?

Hi @RichOB ,

 

If you want the day count just for the selected row (not across the whole table), you can use something like this:

DayCount = 
DATEDIFF(
    SELECTEDVALUE('Table'[StartDate]),
    SELECTEDVALUE('Table'[EndDate]),
    DAY
)

This way, it only calculates the difference for the current row in the visual. If you're using it in a card or matrix, it should now behave as expected.

Let me know if you're working with multiple rows or need to handle blanks — happy to tweak it further!

I'm not sure this is what I'm looking for (maybe it is and I don't understand it! sorry haha). For some reason, this is showing as blank on a card. I have the running total now from this measure:

DaysOpen = DateDiff ('Table'[Start_Date], TODAY (), DAY)

How could I connect this to a line graph? When I try to join the calendar to the Table it asks to join to the Table Start_Date or End_Date but I don't want that as it would give incorrect figures. How do I structure hte calendar to show the correct days open total per month? 

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).

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.