Paulo  
                
                  
                    February 29, 2024,  1:43am
                   
                  1 
               
             
            
              Hello all!
I’m working on a timesheet tracker app to allow each employee can clock in and out, sometimes multiple times a day.
             
            
              
            
           
          
            
            
              Hi @Paulo 
I see [Name] column is type Ref, I assume this is related to an employee table.
 
If you wish to have an aggregation per employee AND per month, then I would suggest creating a new table “month_aggregation” with columns:
 
 
and, in your Timesheet table, adding a virtual column [_month_aggregation], type Ref, source table month_aggregation, with expression:
ANY(
  FILTER("month_aggregation",
    AND(
      [Name]=[_THISROW].[Name],
      [month]=[_THISROW].[month]
    )
  )
)
In your table “month_aggregation”, create a virtual column [_related_timesheet] with this expression: 
 
FILTER("Timesheet",
  IN([_THISROW],[_month_aggregation])
)
in your table “Timesheet”, add a virtual column [_total_hours], type Duration , with this expression: 
 
[Date/Time In]-[Date/Time Out]
In your table “month_aggregation”, create a virtual column [_total_hours], type Duration , with this expression: 
 
[_related_timesheet][_total_hours]
 
            
              
            
           
          
            
              
                Paulo  
                
                  
                    February 29, 2024,  8:00am
                   
                  3 
               
             
            
              Thank you for your help, @Aurelien  !
             
            
              
            
           
          
            
            
              My bad! I forgot to tell you to add a virtual column [_month] in your table TimeSheet.
The expression would be:
MONTH([date/Time In])
And the expression would turn into:
ANY(
  FILTER("month_aggregation",
    AND(
      [Name]=[_THISROW].[Name],
      [month]=[_THISROW].[_month]
    )
  )
)
(just added an underscore before month)
For reference:
MONTH() - AppSheet Help 
For the future, you may want to think about tracking the year as well.
             
            
              1 Like 
            
            
           
          
            
              
                Paulo  
                
                  
                    March 1, 2024,  1:47am
                   
                  5 
               
             
            
              Sorry to bother you again, @Aurelien 
             
            
              
            
           
          
            
            
              Hi @Paulo 
My mistake again ! 
Can you try:
FILTER("Timesheet",
  [_THISROW]=[_month_aggregation]
)
Equivalent to:
REF_ROWS("Timesheet",[_month_aggregation])
For reference:
REF_ROWS() - AppSheet Help 
             
            
              
            
           
          
            
              
                Paulo  
                
                  
                    March 5, 2024,  4:35am
                   
                  7 
               
             
            
              I’m almost there, @Aurelien  !
             
            
              
            
           
          
            
              
                Paulo  
              
                  
                    March 12, 2024,  7:06am
                   
                  8 
               
             
            
              Sorry to bother you again @Aurelien 
             
            
              
            
           
          
            
            
              Hi @Paulo 
My bad again…I forgot to reply, thanks for raising.
Can you try this:
SUM(
    [_related_timesheet][_total_hours]
  )
If you wish to have it under a decimal value, you can try:
TOTALHOURS(
  SUM(
    [_related_timesheet][_total_hours]
  )
)
For reference:
TOTALHOURS() - AppSheet Help 
             
            
              
            
           
          
            
              
                Paulo  
              
                  
                    March 13, 2024,  8:02am
                   
                  10 
               
             
            
              Thank you so much @Aurelien  !
             
            
              1 Like