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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
juhoneyighot
Helper III
Helper III

Time Entry(Log-In/Out) Conditional Formula

Hello!

I have these two tables: 

 

First table shows the available time that a resource can work for a day.

juhoneyighot_0-1710870256977.png

Second Table is from the time entries with actual start and end time

juhoneyighot_1-1710870333718.png

What I want is the status for the actual start and end time with the following conditions:

1 If Actual start time is before the available time then "Early Log-in

2 If the Actual start time is between availabe time and 10min from available time (grace period) then "On-Time". If an resource starts on 7:06 is still "On time" since 7:06 is still in grace period.

3 If the Actual Start Time is beyond the grace period (Available time+10min) then "Late"

 

Same scenario with the status of Actual end time.


Thank you,

 

Juhoney

 

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @juhoneyighot 

 

Thanks for the reply from @MNedix , please allow me to provide another insight:

You can use the Time(Hour('table'[column]),Minute('table'[column]),Second('table'[column])) to get the time from date/time column.

Then it seems that the relationship confused you, maybe you can try this:
First of all, I create a set of sample:

vzhengdxumsft_0-1711431662783.pngvzhengdxumsft_1-1711431669051.png

Next, the crossjoin() function can be useful to create a new table,
Click new table:

 

Table = 
	SELECTCOLUMNS(
		CROSSJOIN(
			'Available',
			'Actual'
		),
		'Available'[Resource],
		'Actual'[Date],
		'Actual'[Actual Start Time],
		"_Start_status",
		IF(
			DATEDIFF(
				'Available'[Available Start time],
				'Actual'[Actual Start Time],
				MINUTE
			) < 0,
			"Early Log_in",
			IF(
				DATEDIFF(
					'Available'[Available Start time],
					'Actual'[Actual Start Time],
					MINUTE
				) > 10,
				"Late",
				"On time"
			)
		),
		'Actual'[Actual End Time],
		"_End_status",
		IF(
			DATEDIFF(
				'Available'[Available End time],
				'Actual'[Actual End Time],
				MINUTE
			) < 0,
			"Early Log-out",
			IF(
				DATEDIFF(
					'Available'[Available End time],
					'Actual'[Actual End Time],
					MINUTE
				) > 10,
				"Late Log out",
				"On time"
			)
		)
	)

 

The sample is very simple that you can use selectcolumns() and calculatetable() function to choose what you need in your two original tables to mix as a new table.

The result is as follow:

vzhengdxumsft_2-1711431982070.png

 

Best Regards

Zhengdong Xu
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

8 REPLIES 8
v-zhengdxu-msft
Community Support
Community Support

Hi @juhoneyighot 

 

Thanks for the reply from @MNedix , please allow me to provide another insight:

You can use the Time(Hour('table'[column]),Minute('table'[column]),Second('table'[column])) to get the time from date/time column.

Then it seems that the relationship confused you, maybe you can try this:
First of all, I create a set of sample:

vzhengdxumsft_0-1711431662783.pngvzhengdxumsft_1-1711431669051.png

Next, the crossjoin() function can be useful to create a new table,
Click new table:

 

Table = 
	SELECTCOLUMNS(
		CROSSJOIN(
			'Available',
			'Actual'
		),
		'Available'[Resource],
		'Actual'[Date],
		'Actual'[Actual Start Time],
		"_Start_status",
		IF(
			DATEDIFF(
				'Available'[Available Start time],
				'Actual'[Actual Start Time],
				MINUTE
			) < 0,
			"Early Log_in",
			IF(
				DATEDIFF(
					'Available'[Available Start time],
					'Actual'[Actual Start Time],
					MINUTE
				) > 10,
				"Late",
				"On time"
			)
		),
		'Actual'[Actual End Time],
		"_End_status",
		IF(
			DATEDIFF(
				'Available'[Available End time],
				'Actual'[Actual End Time],
				MINUTE
			) < 0,
			"Early Log-out",
			IF(
				DATEDIFF(
					'Available'[Available End time],
					'Actual'[Actual End Time],
					MINUTE
				) > 10,
				"Late Log out",
				"On time"
			)
		)
	)

 

The sample is very simple that you can use selectcolumns() and calculatetable() function to choose what you need in your two original tables to mix as a new table.

The result is as follow:

vzhengdxumsft_2-1711431982070.png

 

Best Regards

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

MNedix
Super User
Super User

Yes, you can use Time = FORMAT([Date],"hh:mm:ss")



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Hello

I've use this formula Time = FORMAT([Date],"hh:mm:ss") and get the Available and Actual Start Time See ss below. Is there a formula that I can only get the earliest time for each date? 

juhoneyighot_1-1711037106859.png

Second, I've tried the formula (using the Time format above) to get the Early log-in /late Log in etc however I bumped with this error.

juhoneyighot_0-1711037069303.png

DAX comparison operations do not support comparing values of type Text with values of type Date. Consider using the VALUE or FORMAT function to convert one of the values.

 

Hope you could still help me on this.

 

Thank you.

How do you get multiple times after formatting the column? What changed in the data? You could probably try wrapping it in a FIRSTNONBLANK(Format...) For the second one, it might also be a formatting issue.

This is blowing a bit out of proportion, without looking at your data I cannot see where the problem is coming from. It works fine on my end.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,
MNedix
Super User
Super User

I had to recreate your table and I've added another person just for kicks. The way I did it is as follows:

1. Make sure that you have a relationship between the two tables

2 Create the following column

New Start Status = 
VAR _time = LOOKUPVALUE(Sheet1[Available Start Time],Sheet1[Resource],Sheet2[Resource])
var _delay = TIME(0,10,0)
RETURN
SWITCH(
    TRUE(),
    Sheet2[Actual Start Time]<_time,"Early Log-in",
    Sheet2[Actual Start Time]>_time+_delay,"Late",
    Sheet2[Actual Start Time]>_time ||  Sheet2[Actual Start Time]<=_time+_delay,"On time")

 

(As a rule of thumb, please make sure next time you upload actual data and not a screeshot).

 

Screenshots:

Clock-in_1.jpgClock-in_2.jpgClock-in_3.jpg

 

If this answered your question then please mark it as solution.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Hello!

Thank you. I tried using your formula and this is the result

juhoneyighot_1-1710956887794.png

 

I am not sure why 12:05,12:06,12:07 Start time has been flagged as Late Log-in. I am not sure if I have entered the correct formula you have given. This would be "On Time" since time in is part of a 10min grace period

 

Hope you can help me with this.

 

Thank you

I assume you formatted the columns as Time, right? Can you attach the file? Also, do you have the relationship between 'bookableresource'[Name] and 'msdyn_timeentry'[Bookable Resource]?

 



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Hello!

 

Yes it is formatted as time and I have relationship betwwen the 2 tables. I'm sorry but I can not attached the file since I am working in a cloud. Sharing files is restricted outside organization.

juhoneyighot_1-1711020870920.pngjuhoneyighot_2-1711021192152.pngjuhoneyighot_3-1711021244716.png

 

But I guess I know where is the problem. Data type source for _Available time and Start time is Date and Time 

 

juhoneyighot_4-1711022413253.png

I just change the type as time.

 

So if I have a STart time (which is a date and time format also) from time entry table after the set available time, it will have a Late Log-in.

 

Is there a way if I could get the time in each Start time and Available time without connecting it with the date? Any DAX formula that I could use to get the time?

 

Thank you

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.