Have a timesheets table and it helps with accruing Paid time off. I need to implement a policy that PTO will max out at 160 hours in a running total field. The running total field looks like t...
The problem here is that when someone uses 8 hours of PTO is does not take it into account in the balance field. It still show a balance of 160 instead of 152.
If there is a better way to do running totals without a query I'm all ears.
I have solved a similar problem on Time Off, but attack it differently. There is a Pipeline running monthly that expires the oldest earned time that exceeds the threshold. It also checks seniority and will raise the threshold on an individual basis from the new hire level out to five years when employees max out.
I solved something similar a few years ago using a three table structure, so we could use relationships:
Employee {Parent},
Yearly (calendar) Hours (child),
Time Off Requests (child)
On the Yearly Hours table the employee inputs yearly balance record, Year and Starting Balance, so we can subtract as request records are 'approved'. I query to the sibling table based on the Year (Start Date and End Date) values to get the 'approved' hours. Then on the Time Off Request record we can show the estimated hours taken, and remaining balance.
If you're comfortable with your query structure, then you can always use report formulas to see where they might be wrong. As Mark pointed out, the inputs/parameters to the Min() seem a bit off, but without knowing your intent it's difficult to say. If you're attempt is to get the first value of query one, and if null, then query two, it should be this:
Here are some screenshots of using report formulas, and what the resulting report looks like (just a sample of the report). Because I'm already calculating remaining balance, if I sum it, then it's per record for the query params.