We added a much requested feature to the Forms app (Web and mobile): support of formula.
- Go to the Forms Web app, click on Templates on the left pane
- Create a new Template or click on one of your existing template.
- Add a new Field of type Formula
For example, if you have 2 fields Width and Height with ID F1 and F2, you can create a third field labelled Surface of type formula. The value for this field is simply F1*F2
Note: you can find the ID of each field in the view Template screen on Forms Web app.
- to round the surface, use Math.floor(F1*F2)
- use conditional statement (F1*F2 < 10) ? 10 : F1*F2
A more complex example:
if (F1>=0 && F1<10) 'Low'
else if (F1>=10 && F1<20) 'Medium'
- Format.duration(minutes) to format a duration
- Format.price(amount), currency to format a price. currency parameter is optional
- [number].toFixed(2) to format a number with 2 decimals.
Another example: a Timesheet Form:
- Start time (type time, ID=F1)
- Break (type=duration, ID=F2)
- Stop time (type=Time, ID=F3)
- Total Work Hours (excluding break) is Type=Formula
The formula is simply Format.duration((F3-F1)/60000-F2)
Date and Time field values are always im milliseconds, Duration field value is in minutes. So to compute the duration in minutes between 2 times or dates, substract the 2 values then divide by 6000 (1 minute = 60 s = 60,000 ms)
If you need help creating more complex formula or Forms, just use our Google Group forum here.