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
Anonymous
Not applicable

Charting a date range

Below is an example of data I have.  I have a list of assignments, when they begin and when they end.  As you can see some assignment dates overlap each other meaning they are active during the same time and some do not overlap.  I would like to create a chart where the x-axis shows a calendar month and for each month it counts how many of assignments start and end date overlapped with the calendar month. E.g. looking at the data below for January 2023, I should see a count of 1, February 2023 a count of 2, March 2023 a count of 1, April a count of 2, etc. I would like the calendar to continue to generate new dates as time goes on without having to adjust, so that when a new year begins to just keeps going.  Please assist.

 

Assignment #Start DateEnd Date
55501/04/202302/23/2023
44402/15/202305/01/2023
33304/20/202306/12/2023
22206/13/202307/04/2023

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Thanks @amitchandak  for the quick reply and solution. Here is my alternative approach for your reference:

1.Click "transform data" to enter the power query and add a custom column.

 

List.Dates([Start Date],Duration.Days([End Date]-[Start Date])+1,#duration(1,0,0,0))

 

2.Expand to New Rows.

vtangjiemsft_0-1712211037984.png

3.Changes the data type to a date type.->Close and Apply.

4.We can create a date table.

 

Date = CALENDAR(DATE(2023,1,1),DATE(2024,12,31))

 

5.We can create a measure.

 

Measure = 
var _table=ADDCOLUMNS(ALL('Table'),"Year",YEAR([Custom Date]),"Month",MONTH([Custom Date]))
var _table2=SUMMARIZE(_table,[Assignment #],[Year],[Month])
RETURN 
COUNTROWS(FILTER(_table2,[Month]=MAX('Date'[Date].[MonthNo]) && [Year] =MAX('Date'[Date].[Year])))

 

vtangjiemsft_2-1712211243964.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Thanks @amitchandak  for the quick reply and solution. Here is my alternative approach for your reference:

1.Click "transform data" to enter the power query and add a custom column.

 

List.Dates([Start Date],Duration.Days([End Date]-[Start Date])+1,#duration(1,0,0,0))

 

2.Expand to New Rows.

vtangjiemsft_0-1712211037984.png

3.Changes the data type to a date type.->Close and Apply.

4.We can create a date table.

 

Date = CALENDAR(DATE(2023,1,1),DATE(2024,12,31))

 

5.We can create a measure.

 

Measure = 
var _table=ADDCOLUMNS(ALL('Table'),"Year",YEAR([Custom Date]),"Month",MONTH([Custom Date]))
var _table2=SUMMARIZE(_table,[Assignment #],[Year],[Month])
RETURN 
COUNTROWS(FILTER(_table2,[Month]=MAX('Date'[Date].[MonthNo]) && [Year] =MAX('Date'[Date].[Year])))

 

vtangjiemsft_2-1712211243964.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

 

Anonymous
Not applicable

Hello,

Thank you both for your responses. 

 

When I tried the first approach I am getting this error

tsuarez_2-1712241442555.png

 

When I tried the second approach, after step 3 of close and apply I am getting this message and cannot move forward.  Please assist.

tsuarez_1-1712240929781.png

 

 

Thank you!

 

Anonymous
Not applicable

Hi @Anonymous ,

 

Please disconnect the model relationship in Power BI Desktop then go into power query to process the data then close and apply then connect your model relationship again.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

amitchandak
Super User
Super User

@Anonymous ,With a date table having active join with Start date and inactive join with end date

 

Started = CALCULATE(COUNT(Assignment[Assignment #]),USERELATIONSHIP(Assignment[Start Date],'Date'[Date]) )

Ended = CALCULATE(COUNT(Assignment[Assignment #]),USERELATIONSHIP(Assignment[End Date],'Date'[Date]),not(ISBLANK(Assignment[End Date])))

Active Assignment = CALCULATE(COUNTx(FILTER(Assignment,Assignment[Start Date]<=max('Date'[Date]) && (ISBLANK(Assignment[End Date]) || Assignment[End Date]>max('Date'[Date]))),(Assignment[Assignment #])),CROSSFILTER(Assignment[Start Date],'Date'[Date],None))

 

 

Seem like very similar to HR Analytic Solution

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.