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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rajasekar_o
Helper V
Helper V

logout time

Hi team ,

i have Login logout data, need to calculate  OUT TIME 

out time
if the employee have logout time on that date the take max of logout time ,if ther is no logout time on that date the check nexday before 9:30:00am take that time is logout time other wise is empty 

 

rajasekar_o_0-1706096219967.png

  i try but not come correctly 
21.11.2023 out time is 02:30:02 am

rajasekar_o_2-1706096219550.png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rajasekar_o ,

Please follow these steps:

1.Use the DAX expression shown to create a calculated column named ‘ In Time ’.

 

In time = TIME(HOUR([Datetime]),MINUTE([Datetime]),SECOND([Datetime]))

 

vzhouwenmsft_0-1706176446869.png

 

2. Use the DAX expression shown to create a measure named ‘ Out time ’.

 

Out time =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_dt =
    SELECTEDVALUE ( 'Table'[Datetime] )
VAR cur_date =
    DATE ( YEAR ( cur_dt ), MONTH ( cur_dt ), DAY ( cur_dt ) )
VAR next_date = cur_date + 1
VAR tmp =
    FILTER (
        ALL ( 'Table' ),
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) ) = cur_date
            && [Type] = "OUT"
    )
VAR max_date =
    MAXX ( tmp, [Datetime] )
VAR max_time =
    TIME ( HOUR ( max_date ), MINUTE ( max_date ), SECOND ( max_date ) )
VAR tmp2 =
    FILTER (
        ALL ( 'Table' ),
        [Name] = cur_name
            && DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) ) = next_date
            && [Type] = "OUT"
    )
VAR tmp3 =
    FILTER ( tmp2, [In time] < TIMEVALUE ( "9.30.00 AM" ) )
VAR max_time1 =
    MAXX ( tmp3, [In time] )
RETURN
    IF ( ISBLANK ( COUNTROWS ( tmp ) ), max_time1, max_time )

 

3. Use the DAX expression shown to create a measure for the filter.

 

Measure =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_dt =
    SELECTEDVALUE ( 'Table'[Datetime] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Name] = cur_name && [Type] = "IN" )
VAR tmp1 =
    ADDCOLUMNS (
        tmp,
        "Date", DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) )
    )
VAR tmp2 =
    SUMMARIZE ( tmp1, [Date], "Min_Date", MIN ( [Datetime] ) )
VAR tmp3 =
    SELECTCOLUMNS ( tmp2, "Min_date", [Min_Date] )
RETURN
    IF ( cur_dt IN tmp3, 1 )

 

vzhouwenmsft_1-1706176629630.png

 

4. Final output

vzhouwenmsft_2-1706176659631.png

 

Best Regards,
Wenbin Zhou
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

1 REPLY 1
Anonymous
Not applicable

Hi @rajasekar_o ,

Please follow these steps:

1.Use the DAX expression shown to create a calculated column named ‘ In Time ’.

 

In time = TIME(HOUR([Datetime]),MINUTE([Datetime]),SECOND([Datetime]))

 

vzhouwenmsft_0-1706176446869.png

 

2. Use the DAX expression shown to create a measure named ‘ Out time ’.

 

Out time =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_dt =
    SELECTEDVALUE ( 'Table'[Datetime] )
VAR cur_date =
    DATE ( YEAR ( cur_dt ), MONTH ( cur_dt ), DAY ( cur_dt ) )
VAR next_date = cur_date + 1
VAR tmp =
    FILTER (
        ALL ( 'Table' ),
        DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) ) = cur_date
            && [Type] = "OUT"
    )
VAR max_date =
    MAXX ( tmp, [Datetime] )
VAR max_time =
    TIME ( HOUR ( max_date ), MINUTE ( max_date ), SECOND ( max_date ) )
VAR tmp2 =
    FILTER (
        ALL ( 'Table' ),
        [Name] = cur_name
            && DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) ) = next_date
            && [Type] = "OUT"
    )
VAR tmp3 =
    FILTER ( tmp2, [In time] < TIMEVALUE ( "9.30.00 AM" ) )
VAR max_time1 =
    MAXX ( tmp3, [In time] )
RETURN
    IF ( ISBLANK ( COUNTROWS ( tmp ) ), max_time1, max_time )

 

3. Use the DAX expression shown to create a measure for the filter.

 

Measure =
VAR cur_name =
    SELECTEDVALUE ( 'Table'[Name] )
VAR cur_dt =
    SELECTEDVALUE ( 'Table'[Datetime] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Name] = cur_name && [Type] = "IN" )
VAR tmp1 =
    ADDCOLUMNS (
        tmp,
        "Date", DATE ( YEAR ( [Datetime] ), MONTH ( [Datetime] ), DAY ( [Datetime] ) )
    )
VAR tmp2 =
    SUMMARIZE ( tmp1, [Date], "Min_Date", MIN ( [Datetime] ) )
VAR tmp3 =
    SELECTCOLUMNS ( tmp2, "Min_date", [Min_Date] )
RETURN
    IF ( cur_dt IN tmp3, 1 )

 

vzhouwenmsft_1-1706176629630.png

 

4. Final output

vzhouwenmsft_2-1706176659631.png

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.