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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
krwalke
Frequent Visitor

DAX - Combine WEEKDAY and TIME functions to filter specific date/time ranges

I am building a production schedule and am trying to set up shifts to plan production or not.  I used the below FILTER to designate production between 6am and 10pm on weekdays.  For another equipment center, I'd like to setup a shift that doesn't operate past 2pm on Fridays (they run a 4/10 schedule).  Could someone help me combine the WEEKDAY and TIME filters to account for this?

 

 

var _table = 
    TOPN(
        hours + 1,
        FILTER(
            'Production Gantt',
            'Production Gantt'[Value] > firststartdate && 
            ('Production Gantt'[Value] - INT('Production Gantt'[Value])) > TIME(6,0,0) && 
            ('Production Gantt'[Value] - INT('Production Gantt'[Value])) < TIME(22,0,0) && 
            WEEKDAY('Production Gantt'[Value])<>1 && 
            WEEKDAY('Production Gantt'[Value])<>7
        ), 
        [Value], 
        ASC
    ) return //schedule from 6am through 10pm start times on weekdays.

 

2 REPLIES 2
amitchandak
Super User
Super User

@krwalke , Not very clear. Are you looking for business hours?

https://exceleratorbi.com.au/calculating-business-hours-using-dax/

 

 

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

 

 

The above FILTER code is written and filters another date table ('Production Gantt' - generated list of dates for the next 365 days in units of minutes) by the following:

- time is greater than 6am

- time is less than 10pm

- the day is not Sunday

- the day is not Saturday

 

What I'm looking to add to that is:

- the day is not Friday after 2pm

 

Thanks for the reply and help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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