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

To calculate difference between In time and Out time for bio-metric report

 

Hi ,

 

I am designing a reports on biometric timimngs,but i am facing difficulties to find break timing.

I am attaching a snapshot for more clarifiaction.

 

image.PNG

11:48:11 is shift timing and I have to calculate difference between  13:44:35 and 13:44:08  ,14:41:50 and 14:15:51 ...so on

is there any way to calculate time difference using dax ?

 

Thank You in advance

 

 

Regards,

Vivek Chavan 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please new such a measure:

Diff =
VAR lastOUTTime =
    CALCULATE (
        MAX ( TableA[Out Time] ),
        FILTER (
            ALLEXCEPT ( TableA, TableA[Employee Code], TableA[Date] ),
            TableA[RNK]
                = CALCULATE (
                    MAX ( TableA[RNK] ),
                    FILTER (
                        ALLEXCEPT ( TableA, TableA[Employee Code], TableA[Date] ),
                        TableA[RNK] < MAX ( TableA[RNK] )
                            && TableA[Direction] = "OUT"
                    )
                )
        )
    )
RETURN
    DATEDIFF (
        IF ( SELECTEDVALUE ( TableA[Direction] ) = "IN", lastOUTTime, BLANK () ),
        SELECTEDVALUE ( TableA[In Time] ),
        SECOND
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

5 REPLIES 5
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Please new such a measure:

Diff =
VAR lastOUTTime =
    CALCULATE (
        MAX ( TableA[Out Time] ),
        FILTER (
            ALLEXCEPT ( TableA, TableA[Employee Code], TableA[Date] ),
            TableA[RNK]
                = CALCULATE (
                    MAX ( TableA[RNK] ),
                    FILTER (
                        ALLEXCEPT ( TableA, TableA[Employee Code], TableA[Date] ),
                        TableA[RNK] < MAX ( TableA[RNK] )
                            && TableA[Direction] = "OUT"
                    )
                )
        )
    )
RETURN
    DATEDIFF (
        IF ( SELECTEDVALUE ( TableA[Direction] ) = "IN", lastOUTTime, BLANK () ),
        SELECTEDVALUE ( TableA[In Time] ),
        SECOND
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hey @v-yulgu-msft 

 

Thank You.

 

Your formula worked but when i take multile userid's then it shows like : 

 

Capture.PNG

 

Thanks & Regards,

Vivek Chavan 

Anonymous
Not applicable

Hey guys,

 

Find many difficulties to show break times data for multiple employees, so i am trying to show total minutes worked and total break time but i am not able to calculate total break time.

 

I am attaching a sql query and expected output for clarification :

 

Query :

 

SELECT USERID,EMPLOYEENAME,[DATE],MIN([TIME]) [IN TIME] ,
MAX([TIME]) [OUT TIME],DATEDIFF(MINUTE,MIN([TIME]),MAX([TIME])) [TOTAL HOURS WORKED],DEPARTMENT-- into Timedetails
FROM
(
select
[ROW NUMBER]=(row_number() over(partition by a.USERID order by a.logdate)),
A.USERID,B.EMPLOYEENAME,
CAST(A.LogDate AS DATE) [DATE],
CONVERT(VARCHAR,A.LOGDATE,108) [TIME],
DIRECTION=(CASE WHEN VerificationMode='1' THEN 'IN' ELSE 'OUT' END),
A.VERIFICATIONMODE-- INTO Timedetails
,c.DepartmentFName DEPARTMENT
from DeviceLogs_10_2018 a
inner join
Employees b
on(a.UserId=B.EmployeeCode)
inner join
Departments c
on (b.DepartmentId=c.DepartmentId)
where A.UserId IN ('2298','2299') and cast(A.LogDate as date)='2018-10-17'
GROUP BY B.EMPLOYEENAME,A.LogDate,A.VerificationMode,A.USERID,c.DepartmentFName
)A
GROUP BY USERID,EMPLOYEENAME,[DATE],DEPARTMENT
order by [DATE] desc

 

Expected O/P:

 

Capture.PNG

 

 

Thank You !!

 

Regards,

VivekC

 

Anonymous
Not applicable

 

Hi ,

 

I am designing a reports on biometric timimngs,but i am facing difficulties to find break timing.

I am attaching a snapshot for more clarifiaction.

 

image.PNG

11:48:11 is shift timing and I have to calculate difference between  13:44:35 and 13:44:08  ,14:41:50 and 14:15:51 ...so on

is there any way to calculate time difference using dax ?

 

Thank You in advance

 

 

Regards,

Vivek Chavan 

 

LivioLanzo
Solution Sage
Solution Sage

@Anonymous

could you share your table? and what do you do want to do after having had calculated this value? where should it be displayed?

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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.