Help with maxrow() function

APP FUNCIONALITY
The main function of my app is to scann a certain employee with a scanner field and the app has to give me the ENTRANCE HOUR as well as the EXIT HOUR in order to calculate the hours worked.

The thing is that the user has to scan a card that will be assigned in a field called SCANNER_CARD, and the app automatically has to show me the hour depending of the entry type , (ENTRANCE HOUR or EXIT HOUR)
I know that I can do the time funcionality with timenow() and other funcionts
but I donโ€™t know how to automate this process.

What data do I have?

TABLES

Employees:

Table that has the following columns:
NUMBER (ID)
NAME (TEXT)

Timesheet :

Table that has the following columns
ID_TIMESHEET
SCANNER_CARD (References the NUMBER of the employee that is on employees
table)
DATE-DAY (DATETIME)
ENTRANCE HOUR (TIME)
OUTHOUR (TIME)

What have I tried?

I have tried to use the MAXROW() function to identify the last value of the DATE-DAY column so that I can compare it to the penultimate value of the column DATE-DAY as well

!!!ATTENTION!!!
I have tried to use the MAXROW() function to identify the last value of the DATE-DAY
but from the employee who was scanned not all data in general.

I donโ€™t know how to implement this pseudocode in appsheet expression Iโ€™ve been researching the documentation for over two weeks and I canโ€™t figure it out, please help me:

(assuming I already scanned the employee)

bring me the maxrow of the column DATE-DAY of the employee scanned
and

bring me the penultimate column of DATE-DAY of the same employee scanned

Please, I hope Iโ€™ve made myself clear. Thankyou

0 4 180
4 REPLIES 4

mucho texto

Steve
Participant V

Assuming youโ€™re trying to do this from the employeeโ€™s row in the Employees table, the expression to get the employeeโ€™s latest Timesheet row is:

MAXROW(
  "Timesheet",
  "DATE-DAY",
  ([_THISROW].[NUMBER] = [SCANNER_CARD])
)

To get the DATE-DAY column value from the employeeโ€™s latest Timesheet row:

ANY(
  SELECT(
    Timesheet[DATE-DAY],
    (
      [_THISROW]
      = MAXROW(
        "Timesheet",
        "DATE-DAY",
        ([_THISROW].[NUMBER] = [SCANNER_CARD])
      )
    )
  )
)

I would encourage you to change the clock-in and -out columns to DateTime rather than Time to more easily handle spans that cross days.

Thank you Steve, you are the best

@Jesus_Corral
ahahaโ€ฆyouโ€™re damn right, @Steve is definitely an expression monster

Top Labels in this Space