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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
alex9999
Helper I
Helper I

Create graph that includes all dates between a start and end date

Hi,

 

I want to create a graph where my X axis has months of the year and my Y axis has count of items. The idea is to have the graph include all the months that the item has been hired, which is identified between a start and an end date.

 

For example, if an item has been on-hired January 2024 and off-hired March 2024, the graph will count 1 for January, February and March.

 

I have the idea in my head but I am struggling to execute. My data has [item], [start_date] and [end_date].

 

Thank you.

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@alex9999 

try to create a date table

 

date = CALENDAR(min('Table'[Startdate]),max('Table'[enddate]))
 
then create a measure
Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Startdate]<=min('date'[Date])&&'Table'[enddate]>=max('date'[Date])))
 
11.PNG
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

AnalyticPulse
Super User
Super User

hi @alex9999 You can try below dax and let me know if it works
Items Count =
VAR MinDate = MIN('OnboardOffboardTable'[start_date])
VAR MaxDate = MAX('OnboardOffboardTable'[end_date])
VAR CalendarTable = CALENDAR(MIN(MinDate), MAX(MaxDate))
RETURN
SUMX(
CalendarTable,
CALCULATE(
COUNTROWS('OnboardOffboardTable'),
'OnboardOffboardTable'[start_date] <= CalendarTable[Date] &&
'OnboardOffboardTable'[end_date] >= CalendarTable[Date]
)
)

Learn Power BI free:

https://analyticpulse.blogspot.com

Power BI : getting started

Dax functions

powerbi Visualisation

AnalyticPulse_0-1715829624787.png

 

 

View solution in original post

4 REPLIES 4
AnalyticPulse
Super User
Super User

hi @alex9999 You can try below dax and let me know if it works
Items Count =
VAR MinDate = MIN('OnboardOffboardTable'[start_date])
VAR MaxDate = MAX('OnboardOffboardTable'[end_date])
VAR CalendarTable = CALENDAR(MIN(MinDate), MAX(MaxDate))
RETURN
SUMX(
CalendarTable,
CALCULATE(
COUNTROWS('OnboardOffboardTable'),
'OnboardOffboardTable'[start_date] <= CalendarTable[Date] &&
'OnboardOffboardTable'[end_date] >= CalendarTable[Date]
)
)

Learn Power BI free:

https://analyticpulse.blogspot.com

Power BI : getting started

Dax functions

powerbi Visualisation

AnalyticPulse_0-1715829624787.png

 

 

ryan_mayu
Super User
Super User

@alex9999 

try to create a date table

 

date = CALENDAR(min('Table'[Startdate]),max('Table'[enddate]))
 
then create a measure
Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Startdate]<=min('date'[Date])&&'Table'[enddate]>=max('date'[Date])))
 
11.PNG
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Perfect solution. I did attempt with other forum posts but this one made it very clear to me. Thank you!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.