How can I configure a Laserfiche Form to ensure that if an employee enters a tip amount exceeding 20% of the meal's total, the excess is not calculated or included in the overall total that will be reimbursed? Is this functionality achievable within Laserfiche Forms?
Question
Question
Replies
You could probably use the IF function in a calculation.
IF(booleanValue, value1, value2)
=Meal + IF(Tip>Meal*0.2, Meal*0.2, Tip)
OR
=SUM(Meal, IF(Tip>MULT(Meal,0.2), MULT(Meal,0.2), Tip))
Thank you for the response Jason! Would I input the formula into the "Total" field or the "Tip" field? I've tried using the second formula you provided and added into the "Total" field but when I go to test the form I get an error message "this field contains a calculation error. References: Breakfast:,Tip:.
Thanks again for your help!
The Total field, and for calculations done inside of a table you also need to use INDEX for any of the table variables.
INDEX([variable],ROW())
ROW() is a function that returns the current row in the table or collection, so you can use it in a table to reference variables on the same row.
=SUM(INDEX(Meal,ROW()), IF(Tip>MULT(INDEX(Meal,ROW()),0.2), MULT(INDEX(Meal,ROW()),0.2), Tip))
Also verify your variable names.
Thank you, that worked! I applied the formula you provided with INDEX and ROW, and it's calculating correctly. However, when I add a new date, it simply overwrites the tip calculations from the first date. What adjustments do I need to make so that it calculates based on the amounts entered for the new dates?
Hi Briceida,
You'll need to use INDEX for any variable that is part of the collection; based on your screenshot and formulas, that would include the tip variables you have inside of your IF functions.