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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
petelanglois
Regular Visitor

How to flag lead form submission date/time as falling inside or outside business hours

Hello,

 

I'm trying to create a calculated column which indicates whether a lead submission form arrived inside or outside business hours. This new column would reference an existing date/time column. If the date/time value falls within business hours, I want a new calculated column to read ("true"). If the value falls outside of business hours, I want the new column to read "false". Here's how it would look (my first attempt did not produce correct results - showing the image only as an example).

 

petelanglois_0-1603408142002.png

 

Business hours are 

  • M-F: 8 am - 8pm CST
  • Sat/Sun: 9:30 am - 6pm CST

 

I'm not sure how to calculate this measure. I imagine I need to use IF statements and filter the date/time by day of week as well as time of day, but I'm stumped. Do I need to add a day of week column to the model and use that to distinguish between business hours on Mon-Friday vs business hours on Sat/Sun? Do I need to build in some recognition of time zone, to ensure that the measure always reads the time in the correct zone (opposed to whichever time zone I happen to be in when using power bi)?

 

Thank you for your help!

 

Best,

Pete

 

 

3 REPLIES 3
amitchandak
Super User
Super User

@petelanglois , Try like

new Col =
var _time = [leadenteredDateTime].time
var _day = weekday([leadenteredDateTime],2)
switch(True() ,
_day <= 5 && _time>=time(8,0,0) && && _time<=time(20,0,0) , 1 ,
_day > 5 && _time>=time(9,30,0) && && _time<=time(18,0,0),1,
0)

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

Hi @amitchandak , Thanks for your help. I tried your DAX and this resulted in all results reading "outside". See the dax below. Any ideas what's happening?

 

IsBusinessHoursLead =
var _time = DimLeads[LeadEnteredDateTime]
var _day = weekday(DimLeads[LeadEnteredDateTime],2)

return
switch(True() ,
_day <= 5 && _time >= time(8,0,0) && _time <= time(20,0,0) , "inside",
_day > 5 && _time >= time (9,30,0) && _time <= time(18,0,0), "inside", "outside" )

 

 

Hi, @petelanglois , you might want to try this formula in the calculated column

Col =
VAR __time = TIMEVALUE ( DimLeads[LeadEnteredDateTime] )
VAR __weekday = WEEKDAY ( DimLeads[leadenteredDateTime], 2 )
RETURN
    SWITCH (
        TRUE (),
        __weekday <= 5
            && __time >= TIME ( 8, 0, 0 )
            && __time <= TIME ( 20, 0, 0 ), "inside",
        __weekday > 5
            && __time >= TIME ( 9, 30, 0 )
            && __time <= TIME ( 18, 0, 0 ), "inside",
        "outside"
    )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.