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
jemahusay
Frequent Visitor

Select the First & Last Door Access per Employee Id and Date Within Shift

Hi Everyone,

 

Good day!

 

Hoping to get some help on below problem.

 

I have a table containing multiple door accesses of employees in a period. I also have another table where it contains the shifts and the earliest allowed time in and latest allowed time in a shift. I want to capture the first & last door access that was made but should be within the earliest allowed time in and latest allowed time in. My problem now is with employees who are on the 3rd shift where they make their first door access on the current day and they make their last door access the following day. Also, there are some who makes door access earlier than the earliest allowed time in and makes door access beyond the latest allowed time in. Additional problem is that there are multiple door accesses in between. Below are my tables.

 

Door Accesses Table

2017-08-04_22h50_50.png

 

Shift Table

2017-08-04_22h53_12.png

 

Result Table

2017-08-04_22h53_38.png

 

Thanks a lot in advance for the help.

 

Jerry

 

 

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@jemahusay

I tried to identify the shift date for each door access rows with a calculate column as below and then find the min and max datetime in each shift. . See more details in the attached pbix.

SHIFT ON =
IF (
    HOUR ( yourTable[DATE] ) >= 17,
    DATEVALUE ( yourTable[DATE] ),
    IF (
        HOUR ( yourTable[DATE] ) <= 13,
        DATEVALUE ( yourTable[DATE] ) - 1,
        BLANK ()
    )
)

 

Capture.PNG

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee

@jemahusay

I tried to identify the shift date for each door access rows with a calculate column as below and then find the min and max datetime in each shift. . See more details in the attached pbix.

SHIFT ON =
IF (
    HOUR ( yourTable[DATE] ) >= 17,
    DATEVALUE ( yourTable[DATE] ),
    IF (
        HOUR ( yourTable[DATE] ) <= 13,
        DATEVALUE ( yourTable[DATE] ) - 1,
        BLANK ()
    )
)

 

Capture.PNG

haozhong
Resolver I
Resolver I

Hey, where's the question? Maybe itemised what you want to achieve and we try to 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.