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
Anonymous
Not applicable

Working hours column is only returning true value.

Hi guys,
I'm currently working on a report where I need to measure the time in minutes and seconds between 2 date columns (Task Reported Date, Task Saved Date)  considering only working days and working hours 08:00-18:00 Mon - Fri. 
To achieve this I have created a calculated column with an IF statement which seperates the working days from non working days as a simple Yes or No.
However, only the value for true is returned. Regardless  of the filters. And I am unsure why this is the case. When I add the column to my report, it only shows "No" and not the other results.

Here is the code for the column

Working Hours = IF(OR(FM_Task_Detail[Task Reported Date] < TIME(08,00,00), FM_Task_Detail[Task Reported Date] > TIME(18,00,00)), "No", "Yes")

I will also attach a small sample of the data so you can see what is happening.
Sample Data.PNG
1 ACCEPTED SOLUTION

@Anonymous -

 

Try:

Column 3 =
IF (
    WEEKDAY ( Table1[TaskReportedDate], 3 ) < 5,
    IF (
        AND (
            TIME ( HOUR ( Table1[TaskReportedDate] ), MINUTE ( Table1[TaskReportedDate] ), 0 )
                > TIME ( 8, 0, 0 ),
            TIME ( HOUR ( Table1[TaskReportedDate] ), MINUTE ( Table1[TaskReportedDate] ), 0 )
                < TIME ( 18, 0, 0 )
        ),
        "yes",
        "no"
    )
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

8 REPLIES 8
Anonymous
Not applicable

You are looking in between 8-18 Hrs < I think you should chnage logic :

 

Working Hours = IF(OR(FM_Task_Detail[Task Reported Date] > TIME(08,00,00), FM_Task_Detail[Task Reported Date] < TIME(18,00,00)), "No", "Yes")

Anonymous
Not applicable

Hi,
Thanks for getting back to me. I added the code given. Still having the same issue, but the formula makes more sense logically.

Anonymous
Not applicable

What Error Is u getting? and please post expected output

Anonymous
Not applicable

The data source for this file is Direct Query, so I wouldn't be able to share unfortunately (Corporate Data).

Also, I'm not receiving any kind of error. The column is just not returning the expected output.
This is an example of what I would expect the output to be.

Sample Expected output.PNG
Anything between Monday to Friday 08:00-18:00, excluding weekends. Working Hours should return "Yes".
Before 08:00 and after 18:00,Including weekends should return "No".

Here is the column code also

Working Hours = IF(OR(FM_Task_Detail[Task Reported Date] < TIME(08,00,00), FM_Task_Detail[Task Reported Date] > TIME(18,00,00)), "No", "Yes")

 

@Anonymous -

 

Try:

Column 3 =
IF (
    WEEKDAY ( Table1[TaskReportedDate], 3 ) < 5,
    IF (
        AND (
            TIME ( HOUR ( Table1[TaskReportedDate] ), MINUTE ( Table1[TaskReportedDate] ), 0 )
                > TIME ( 8, 0, 0 ),
            TIME ( HOUR ( Table1[TaskReportedDate] ), MINUTE ( Table1[TaskReportedDate] ), 0 )
                < TIME ( 18, 0, 0 )
        ),
        "yes",
        "no"
    )
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

Excellent! 
Thank you very much Chris 🙂 

Anonymous
Not applicable

Try this :

 

if = if(OR(hour(FM_Task_Detail[Task Reported Date])<8 ,hour(FM_Task_Detail[Task Reported Date])>18),
"NO","Yes"
)
Anonymous
Not applicable

Could you possibly share the csv file?

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.