Solved

field calculation that rounds up to a "nearest value"

Posted on 2008-06-19
3
820 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FM Exporting Pictures In Container 1 966
Filemaker Output 6 211
open URL to email message in apple mail from filemaker 1 118
Create simple calculated field in filemaker pro 10 4 36
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now