Forum Discussion

BrianGardner's avatar
BrianGardner
Qrew Trainee
6 years ago

Sum hours by pay period

Trying to sum time cards by pay period. I have one table to collect hours worked.
Table is "Time Cards". Contains [Date], [Job], [Employee], [Hours].
Have also built a Pay Periods table for 2019 that contains [Pay Period], [Beginning Date], [Ending Date], [Pay Date]
Pay periods are every two weeks starting on 12/31/18.
Pay Periods has a one to many relation to Time Cards.
At the end of my pay period, I need to add up the hours worked by employee for that pay period.
I can make a simple report against the Time Cards by date with a filter that prompts for beginning date and ending date, but the leads to potential errors when selecting the correct date range, so I would like to either attach the appropriate pay period number to a time card record and then group by that, or run a report on pay periods and group by the period.
The part I'm stuck on is assigning a date to the pay period range, unless my thinking is wrong and there's a better approach? I previously did this in Excel via a VLOOKUP formula.

21 Replies

  • no problem.  FirstDayOfPeriod function to the rescue.  It was really designed for your exact use case, like a very typical 2 week pay cycle than never changes come hell or high water.

    Change the Key field of your pay periods table to be the field [Beginning Date]

    The on the details time entries make a formula field for Pay Period beginning date

    https://login.quickbase.com/db/6ewwzuuj?a=dr&r=bm&rl=w5j

    FirstDayOfPeriod([date field], Weeks(2), Date(2018,12,31))

    Use that field as the reference field on the left side if the relationship were 1 pay period record has many time entries and then make your summary field.
  • That works very nicely, thank you.
    Taking this one step further, on my time card form where I now see the pay period drop down box, it would be great if the value of the pay period defaulted to the correct period for the date of the time card. In other words, when I create a new time card entry and select the date I worked, have the pay period set to the correct period for that date. I want to say this should be a filter or dynamic form rule, but I can't quite make the connection.
  • Ok, try this

    Make a formual date field called first day of current time period.

    The formula will be firstdayofperiod(today(), weeks(2), Date(2018,12,31))

    Then have a form rule to fire that says when the pay period date is blank change pay period blank to gr value in the field first day of current time period.

    There is a chance that you will need to put that field on the bottom of the form to get that form rule to fire. Also set that checkob on t(e form rule to unchecked, to be sure it fires.
  • I don't know if I got myself worked around in knots on this, but I seem to have it working...not exactly as you described but I am able to confidently enter time and report on it for payroll purposes.

    I very much appreciate your help on this.
    Brian
  • Hi, this is my first time responding to the community, but I had the exact same problem and resolved it using the automation feature.

    Essentially, when someone enters a time card entry, the automation is triggered based on (adding or modifying) the "Date Worked" field in the Time Card table. After the date is entered, the automation has Quick Base to see if the "Date Worked" value falls between one of the (Payroll Calendar Table) "Beginning Date" and "End Date" values, each pair has an associated Payroll Period.

    Once QB determines which record ID# row (where the Date Worked fell between a begin and end date on payroll calendar), it copies the Payroll Period (and any other associated fields) to a third, many-to-many table that is linked to both the Payroll and Time Card tables.

    If you still are looking for a solution, I can provide screen shot details of the automation, relationships and tables.

    • BrianGardner's avatar
      BrianGardner
      Qrew Trainee
      I would be interested in seeing how you configured the automation and relationships. I'm getting stuck at the automation, and i didn't quite follow why you copied to a third table. Is the extra table there for something else too? I'm thinking I could just copy it back to my time card entry...
  • That sounds very interesting. What I ended up doing works, but still leaves open the possibility of choosing the wrong period.
  • MichelleChapman's avatar
    MichelleChapman
    Qrew Assistant Captain
    I would be interested in seeing screenshots of the automation details and table relationships. I am working on a payroll app and we have a non traditional pay period set up. Employees are paid the 15th and last day of every month. Most are salary so the period is the 1st-15th and 16th-last day-which varies..so the 2 week time period concept isn't working.
  • MichelleChapman's avatar
    MichelleChapman
    Qrew Assistant Captain
    I cannot figure out an automation to identify the pay period.
     I looked at dynamic form rules but don't see a way for it to change the pay period based on the date entered falling into a date range on the payroll calendar table. There was not a during option just on, before, after etc.
     I looked at automations and I just don't know how it identifies the date range and where its goes after that. The only options I get keep expecting me to be able to identify the pay period number when it is going into the table?
  • I do not believe that this required an Automation.  Can you explain the full question.  Are you looking to have a table for all the pay periods then a summary of the hours worked by Employee (EE)?

    If so I would create a table for all the pay periods, loading up with Excel with a key field which identified the YYYYMM1/2

    for example

    201901-1
    201901-2

    that would mean the par periods 1 and 2 for the 2019 January.

    Then have each detail time entry self calculate which pay periods they calculate to by building a formula to make that text string.

    Post back if you need help with the formula.




    • MichelleChapman's avatar
      MichelleChapman
      Qrew Assistant Captain
      So far I have a table employees record [Staff Member](linked table) [Date] ...[Number of Hours] and I created a Payroll Calendar Table with [Pay Period] [Beginning Date] [Ending Date] [Pay Date](Which is always the ending date). I added a look up field on the time entry table that would allow the user to choose their pay period but I want it to assign the pay period. I tried to create a 3rd table as Damon described "Payroll" but do not understand how he got the automations/actions to match the Date in the time entry table with the Pay Period from another table to copy the 2 records into one on the Payroll table.
    • MichelleChapman's avatar
      MichelleChapman
      Qrew Assistant Captain
      I am happy to try it another way. I started with trying to build it how Brian and you were working out at the beginning of this thread but since we don't use a traditional 2 week pay period I was struggling and tried to see what Damon did.
    • MichelleChapman's avatar
      MichelleChapman
      Qrew Assistant Captain
      I added a field that identifies the pay periods as you described. I would need help creating a formula. I could imagine a really long formula that could result in those numbers but not one that will pull the related pay period.