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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX - month-based bar chart for data with date range

Hi Experts,

 

I want to plot the count of the number "working days"(like networkdays) of leaves taken by employee per month.

But the data is in date-range, can you please guide me on how can i calculate the number of days in each date range with in a month.

 

Sample data and expected result is attached.

 

Reagrds

DIvya Joy

 

ID NumberFull NameLeave Type DescripionLeave Start DateLeave End DateDate PaidJan-18Feb-18Mar-18Apr-18May-18Jun-18Jul-18Aug-18Sep-18Oct-18Nov-18Dec-18Jan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19
1234DavidSick7/09/201814/09/20183/10/20180000000070000000000
1234DavidSick27/09/201827/09/201817/10/20180000000010000000000
1234DavidAnnual5/11/20185/11/201814/11/2018                   
1234DavidSick7/11/20187/11/201828/11/2018                   
1234DavidSick9/11/20189/11/201828/11/2018                   
1234DavidAnnual27/12/20189/01/20199/01/2019                   
1234DavidAnnual10/01/201910/01/201923/01/2019                   
1234DavidAnnual11/01/201914/01/201923/01/2019                   
1234DavidSick29/01/201929/01/20196/02/2019                   
3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

A date table will do what you need.  You can simple count the rows inside the date table.  If you need to exclude weekends from the count, you can use the functions in both Power Query or DAX to flag rows as being on the weekend, then simply exclude them from the count.

View solution in original post

amitchandak
Super User
Super User

Please try the following. The assumption is that you have a date table and that is joined with paid date

Also refer to blog :https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

leaves= CALCULATE(COUNTx(FILTER(Employee,Employee[Leave Start Date]<=max('Date'[Date]) && (ISBLANK(Employee[End Date]) 
|| Employee[Leave End Date]>max('Date'[Date]))),(Employee[Employee Id ])),CROSSFILTER(Employee[Date Paid],'Date'[Date],None))	

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

dax
Community Support
Community Support

Hi @Anonymous ,

You need to transform data structure and create calendar table to achieve this goal. You could refer to my sample for details.

Best Regards,
Zoe Zhi

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

5 REPLIES 5
dax
Community Support
Community Support

Hi @Anonymous ,

You need to transform data structure and create calendar table to achieve this goal. You could refer to my sample for details.

Best Regards,
Zoe Zhi

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

Anonymous
Not applicable

This is amazing, just written using 2 measures..  

amitchandak
Super User
Super User

Please try the following. The assumption is that you have a date table and that is joined with paid date

Also refer to blog :https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

leaves= CALCULATE(COUNTx(FILTER(Employee,Employee[Leave Start Date]<=max('Date'[Date]) && (ISBLANK(Employee[End Date]) 
|| Employee[Leave End Date]>max('Date'[Date]))),(Employee[Employee Id ])),CROSSFILTER(Employee[Date Paid],'Date'[Date],None))	

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

A date table will do what you need.  You can simple count the rows inside the date table.  If you need to exclude weekends from the count, you can use the functions in both Power Query or DAX to flag rows as being on the weekend, then simply exclude them from the count.

Anonymous
Not applicable

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors