How to do a “Grand Total” across all records.

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Using Tap Forms How to do a “Grand Total” across all records.

Viewing 5 reply threads
  • Author
  • January 6, 2022 at 9:25 PM #46248

    Dale Peterson

    I just created a very simple DB for my part time woodworking business. It’s basically an “all income sales” DB. I sell several products to several customers. Each of my customer records show what they ordered, how many of each item they ordered, and then calculating their total purchase on one given day. The final income ends up within the “Grand Total” field from their one day purchase.

    My question is: I also have a field titled “Total Shop Income” in each of my customer’s records. My request is to show the sum of “all” sales within this field in each record for a total from all records. In other words, I’d like to show a running total income from all customers within this single field within each record. (See attached screen shot.)

    Thanks, Dale.

    You must be logged in to view attached files.
    January 7, 2022 at 12:58 AM #46250

    Sam Moffatt

    Create a new script field, delete all of the boilerplate it creates and then double click on the field you want to total, it should look like this:

    var order_cost = record.getFieldValue('fld-acdbf6132877436d8f86d12a7a732a13');

    Delete the text before record.getFieldValue and replace it with form.getTotalOfField, it should look like this:


    The exact text of the fld- stuff will be different based on your actual field.

    January 7, 2022 at 3:39 AM #46252


    Alternatively if you click the ID button on the Script Editor, you’ll get a variable assigned to the Field ID of the selected field. Then you can use that in the getTotalOfField() function.

    I prefer to see the Field IDs as separate things because when you look at the code it’s hard to see what field you’re getting the total from.

    For example:

    var order_cost_id = 'fld-acdbf6132877436d8f86d12a7a732a13';
    var order_cost_total = form.getTotalOfField(order_cost_id);

    I know it’s two lines instead of one, but it’s easier to read then.

    January 7, 2022 at 11:20 AM #46254

    Dale Peterson

    Thanks, Brendan and Sam. I got it to work, but it’s not showing in the field as currency even though I have that selected as the “Number Format”. Not a big deal.

    Thanks again for your wonderful help, Dale.

    January 7, 2022 at 11:05 PM #46259

    Sam Moffatt

    In the script editor, make sure the return type is set to be a number in addition to the number format setting in the field settings. The default for script fields is text.

    January 8, 2022 at 4:21 PM #46263

    Dale Peterson

    Sam, you are my rock star of the day! Thanks so much, Dale.

Viewing 5 reply threads

You must be logged in to reply to this topic.