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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
rgalvez
Frequent Visitor

Working hours with UTC times

Hello experts!

 

I have two tables:
Table 1 has all the users list, which includes the time zone where each user lives.  Table 2 has a completion date for each user. Many completions per user, in UTC format.   Tables are linked one-to-many through the UserID.

Table 1 (one):

UserIDUser NameTime Zone
1John DoeEST
2Jane DoeCST
3Jack DoePST

 

Table 2 (many):

UserIDCompleted Date
15/9/2023 3:30:11 AM
26/13/2023 8:15:25 PM
38/12/2022 7:08:10 PM


I need to calculate, based on the user timezones, which completed dates happened after working hours for each user, consdering the end of the day at 6:00 pm.

Examples:

- UserID 2, lives in CST time (UTC -6). The user completed the task on 6/13/2023 at 8:15 PM (UTC),  which means the user completed the task at 2:15 pm (CST), which falls in working hours for the user.

 

- UserID 1, lives in PST time (UTC -8). The user completed the task on 5/9/2023 at 3:30 AM (UTC),  which means the user completed the task at 7:30 PM (PST of the previous day), which falls out of working hours for the user.

 

My challenge is to calculate which completed dates fall out of working hours.

 

Thanks for your support!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rgalvez 

1.You can create a new table(TimeZone) as follows:

vxinruzhumsft_0-1687486116891.png

2.Then create a one-many relationship between timezone table and table 1

vxinruzhumsft_3-1687486440376.png

 

3.Then create a calculated column in table 2

IfOvertime =
VAR a =
    RELATED ( 'TimeZone'[Timedifference] )
VAR b =
    CONVERT (
        FORMAT ( 'Table 2'[Completed Date] - TIME ( a, 0, 0 ), "General Date" ),
        DATETIME
    )
VAR c =
    CONVERT ( DATEVALUE ( b ) & " " & TIME ( 18, 0, 0 ), DATETIME )
RETURN
    IF ( b > c, "Yes", "No" )

Output

vxinruzhumsft_4-1687486609782.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
rgalvez
Frequent Visitor

Hi Yolo!  This worked like a charm.  Thank you so much!

Anonymous
Not applicable

Hi @rgalvez 

1.You can create a new table(TimeZone) as follows:

vxinruzhumsft_0-1687486116891.png

2.Then create a one-many relationship between timezone table and table 1

vxinruzhumsft_3-1687486440376.png

 

3.Then create a calculated column in table 2

IfOvertime =
VAR a =
    RELATED ( 'TimeZone'[Timedifference] )
VAR b =
    CONVERT (
        FORMAT ( 'Table 2'[Completed Date] - TIME ( a, 0, 0 ), "General Date" ),
        DATETIME
    )
VAR c =
    CONVERT ( DATEVALUE ( b ) & " " & TIME ( 18, 0, 0 ), DATETIME )
RETURN
    IF ( b > c, "Yes", "No" )

Output

vxinruzhumsft_4-1687486609782.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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