Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Column = VAR __DateTime = [DateTimeColumn] VAR __Hour = HOUR(__DateTime) VAR __Result = IF( __Hour >= 17 || __Hour < 9 || WEEKDAY(__DateTime,2) > 5,1,0) RETURN __Result
Can anyone help/tell me why when I add another column and change thr hours to >= 6 and <8. It doesnt work. It gives a 1 in every row and no 0?
Solved! Go to Solution.
Hi @lennox25 ,
You may need to reconsider the logic of the code. The logic of OR (||) is to output true if one of the conditions holds, for __Hour >= 6 && __Hour < 8, one of the times of day must be satisfied, so the result is always 1.
Based on the field name, please check if this is the result you want.
Out of Hours Emails Recd 06:00 to 08:00am =
VAR __DateTime = [Date & Time]
VAR __Hour = HOUR('Tablemailbox'[Time])
VAR __Result = IF( __Hour >= 6 && __Hour <8 || WEEKDAY(__DateTime,2) > 5,1,0)
RETURN
__Result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @Anonymous ,
It still doesnt work. I have created a sample file, please take a look.https://drive.google.com/file/d/13V4d_qh2NdCOWQaAri2myVGPruxO04-A/view?usp=sharing
Hi @lennox25 ,
You may need to reconsider the logic of the code. The logic of OR (||) is to output true if one of the conditions holds, for __Hour >= 6 && __Hour < 8, one of the times of day must be satisfied, so the result is always 1.
Based on the field name, please check if this is the result you want.
Out of Hours Emails Recd 06:00 to 08:00am =
VAR __DateTime = [Date & Time]
VAR __Hour = HOUR('Tablemailbox'[Time])
VAR __Result = IF( __Hour >= 6 && __Hour <8 || WEEKDAY(__DateTime,2) > 5,1,0)
RETURN
__Result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Perfect! Thank you @Anonymous
Hi @lennox25 ,
Is [DateTimeColumn] a column or a measure?
If they are all columns, there should be no problem with the code.
Or you can provide some sample data and explain the expected output.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.