cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Create calendar only with workdays

Hi everyone,

 

I`m trying to create a working day calendar with DAX. Does anyone have a suggestion?

Can i exclude days from the calendar function? or can i join more than one intreval of dates?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Responsive Resident
Responsive Resident

Re: Create calendar only with workdays

Yes, you can do that, try this:

 

 

Working Days Calendar = 
var cal = ADDCOLUMNS(CALENDAR(date(2020,4,1), date(2020,5,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),[Date]))
var workingcal =  SUMMARIZE(filter(cal,isblank([Working Date])=false()),[Working Date])

var cal2 = ADDCOLUMNS(CALENDAR(date(2020,1,1), date(2020,2,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),[Date]))
var workingcal2 = SUMMARIZE(filter(cal2,isblank([Working Date])=false()),[Working Date])

return union(workingcal,workingcal2)

 

 

You can also filter out specific dates with a switch statement:

 

Working Days Calendar = 
var cal = ADDCOLUMNS(CALENDAR(date(2020,4,1), date(2020,5,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),switch([date],date(2020,4,1),blank(),[Date])))
var workingcal =  SUMMARIZE(filter(cal,isblank([Working Date])=false()),[Working Date])

var cal2 = ADDCOLUMNS(CALENDAR(date(2020,1,1), date(2020,2,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),[Date]))
var workingcal2 = SUMMARIZE(filter(cal2,isblank([Working Date])=false()),[Working Date])

return union(workingcal,workingcal2)

 

View solution in original post

3 REPLIES 3
Highlighted
Responsive Resident
Responsive Resident

Re: Create calendar only with workdays

Yes, you can do that, try this:

 

 

Working Days Calendar = 
var cal = ADDCOLUMNS(CALENDAR(date(2020,4,1), date(2020,5,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),[Date]))
var workingcal =  SUMMARIZE(filter(cal,isblank([Working Date])=false()),[Working Date])

var cal2 = ADDCOLUMNS(CALENDAR(date(2020,1,1), date(2020,2,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),[Date]))
var workingcal2 = SUMMARIZE(filter(cal2,isblank([Working Date])=false()),[Working Date])

return union(workingcal,workingcal2)

 

 

You can also filter out specific dates with a switch statement:

 

Working Days Calendar = 
var cal = ADDCOLUMNS(CALENDAR(date(2020,4,1), date(2020,5,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),switch([date],date(2020,4,1),blank(),[Date])))
var workingcal =  SUMMARIZE(filter(cal,isblank([Working Date])=false()),[Working Date])

var cal2 = ADDCOLUMNS(CALENDAR(date(2020,1,1), date(2020,2,1)),"Working Date",if(WEEKDAY([Date]) in {1,7},blank(),[Date]))
var workingcal2 = SUMMARIZE(filter(cal2,isblank([Working Date])=false()),[Working Date])

return union(workingcal,workingcal2)

 

View solution in original post

Highlighted
Super User IV
Super User IV

Re: Create calendar only with workdays

You can refer to the calendar in this file. The weekend has been excluded from workday

https://www.dropbox.com/s/y47ah38sr157l7t/Order_delivery_date_diff.pbix?dl=0

 

Other you can update from holiday table

New column in calendar getting holiday from other table

New Column = maxx(filter(table2,table2[Col1]= table1[col1] && table2[Col2]= table1[col2] ),table2[required_col])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Helper I
Helper I

Re: Create calendar only with workdays

Thanks @DataZoe it worked just fine

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors