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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
RichOB
Post Partisan
Post Partisan

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).
translation and formatting supported by AI

View solution in original post

5 REPLIES 5
burakkaragoz
Super User
Super User

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.
translation and formatting supported by AI

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!
translation and formatting supported by AI

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).
translation and formatting supported by AI

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors