Solved

field calculation that rounds up to a "nearest value"

Posted on 2008-06-19
3
826 Views
Last Modified: 2010-04-21
In our invoice/billing system, our technicians clock in and out of each work ticket. We have a field that calculates the "time billed" based on these time ins and outs (there can be up to three ins and outs on each ticket).

Currently our method is as listed in the code snippet. This field calculates to the minute, so if we clock in at 10:00 and clock out at 10:08 it calculates 8 minutes. A change in our pricing structure has been made so that there is a minimum of 15 minutes for service calls (and time is billed in 15 minute increments).

We would like to change this field so that for each time in/out instance, it rounds UP to the nearest 15 minute increment (IE 15, 30, 45, 60, etc..). It would round for each time in/out instance, then add those (up to) three values for the "total time".

Also, should we create a new field for this? We don't want to recalculate any of the existing data as that would change values on outstanding invoices. Currently it is set in storage options to "recalculate as needed".

Thanks!
(BILLING_ITEMS::TIME_OUT_1 - BILLING_ITEMS::TIME_IN_1) + (BILLING_ITEMS::TIME_OUT_2 - BILLING_ITEMS::TIME_IN_2) + (BILLING_ITEMS::TIME_OUT_3 - BILLING_ITEMS::TIME_IN_3)

Open in new window

0
Comment
Question by:Eroots
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
billmercer earned 250 total points
ID: 21825866
Here's a simple formula that will "round up" to the next 15.

 Ceiling( NumberOfMinutes / 15) * 15

If you enter any number of minutes from 1 to 15, it returns 15. If you enter 16, it returns 30, and so forth.

With regard to your history, you definitely don't want to change historical data, so creating a new field for this purpose might be a good idea, but it might also complicate things if you have lots of references to the old field.

One way you could handle that would be to make your calculation conditional on the invoice date. Apply the old calculation for records created before a specific cut-off date, and the new one for any created after that date.


If ( InvoiceDate  >=  "5/1/2008" ;
   Ceiling( NumberOfMinutes / 15) * 15;
   NumberOfMinutes
)

This formula applies the rounding up function to any records with a date of 5/1/08 or later, and simply returns the original number for earlier dates.
0
 

Author Closing Comment

by:Eroots
ID: 31468799
Thanks for introducing the ceiling function, but it took me a while to figure out the whole calculation as it applies to minutes. Here is what I came up with:

(Ceiling ((( Hour ( BILLABLE_TIME )*60)+Minute ( BILLABLE_TIME )) / 15 ) * 15) * 60
0
 
LVL 19

Expert Comment

by:billmercer
ID: 21846193
Hmm, you didn't mention anything about needing to calculate the time difference in your original question, and said you'd already done that before, so I assumed you already knew how.

The formula you used works, but there's a simpler way.

FileMaker times are stored as numbers of seconds internally. They are displayed with formatting to show hours, minutes, etc, but internally it's just a number of seconds.

That means you can do normal math with time values. If you subtract Time A from Time B, you get the difference between the two times in seconds.

Assuming BILLABLE_TIME = END_TIME - START_TIME then all you need to do is

  Ceiling(  BILLABLE_TIME / 60 / 15 ) * 15


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Pop up windows can be a useful feature of any Filemaker database.  Though best used sparingly, they can be employed in a multitude of different ways, for example;  as a splash screen at login, during scripted processes to control user input, as pick…
Having just upgraded from Filemaker 11 to Filemaker 12 over the weekend, we thought we would add some tips for others making the same move.  In general, our installation went without incident. Please note that this is not a replacement for Chapter 5…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question