Clocking App Issues

I'm writing a clock in/clock out app and have both a [Users] table, and a [Log] table.

The [Log] table keeps a record of every action, clocked in or clocked out. The [Users] table keeps a record of whether a person is currently clocked in, or clocked out.

How can I automatically update the allowable action depending on the current status of the user?

For example: If the user is currently clocked out, how can I make sure the only option presented is to clock in?

Referencing the [Users] table I can SELECT() the data, but it doesn't play well with the ENUM. 

SELECT(Users[Action], ([Employee Email] = [_THISROW].[Employee Email]))

I don't know how to correctly wrap this expression to make it function like an IF() for the button to pre-select "Clock In" or "Clock Out" so the user cannot clock in or out twice in a row.

0 1 53
1 REPLY 1

There may be other issues with your intended design, but the following may help. If not, I suggest elaborate, including with screenshots, more about your column types and where you're trying to use the expression you're crafting.

One possibility is that you just need to wrap your SELECT function, which returns a list (even if that list comprises only a single item), within another function that returns a value from the list. For example, using INDEX:

INDEX(SELECT(Users[Action], ([Employee Email] = [_THISROW].[Employee Email])), 1)

Potentially, you don't even need SELECT. If your [Employee Email] (or another) column is a Ref type column from Log to Users, you can likely use a dereference expression. For example:

[Employee Email].[Action]

If you need to return a Yes/No value for use within an IF function, you can simply follow whatever expression you land on with an evaluation of equivalence to whatever value you're comparing against. For example:

INDEX(SELECT(Users[Action], ([Employee Email] = [_THISROW].[Employee Email])), 1) = "Clock Out"

 

Top Labels in this Space