How to create a dynamic running total in a form

How to create a dynamic running total in a form

Running total can help you to dynamically calculate the cumulative sum of values as new entries are added. This provides real-time insights into accumulating data, enriching analytical capabilities within your application, whether you're monitoring expenses, sales, or any other numerical data.
For example, assume the Zoho Creator application is utilized within an organization for sales-related operations. Users consistently log new sales transactions into the system, and they require instant visibility into the total sales figures as transactions are added. By incorporating a running total feature, users can seamlessly track the cumulative sum of all sales entered in real-time. This empowers them to effectively monitor progress towards achieving targeted sales goals.
  1. Navigate to the form builder of the form in which you want to incorporate the running total. Include two currency fields. Designate one for calculating the total within the form and the other to compute the running total based on the accumulated data from the first currency field.

    In this tutorial, for demonstration purposes, we have used the 'Pay an Invoice' form from the form template, added an additional Currency field 'Running_Total', and set its initial value to '0' from its field properties to calculate the running total for the 'Invoice Amount' currency field already available in the form template.

     

    Form Name

    Form Link Name

    Field Type

    Field Name

    Fied Link Name

    Pay an Invoice

    Pay_an_Invoice

    Currency

    Invoice Amount

    Invoice_Amount

    Currency

    Running Total

    (Initial value: 0)

    Running_Total

     

  2. Create a new workflow to execute on the Successful form submission of the Pay an Invoice form with the record event as Created or Edited.

  3. Click Add New Action > Deluge Script and add the following script to the Deluge editor.
    1. if(Running_Total == 0)
    2. {
    3. //When creating a new record, calculate the sum of all values of the 'Invoice_Amount' field in previous records and update the 'Running_Total' field accordingly.
    4.  newTotal = <Form_Link_Name>[ID != 0].sum(Invoice_Amount);
    5.  input.Running_Total = newTotal;
    6. }
    7. else
    8. {
    9. //When editing a record, update the 'Running_Total' field for the current record as well as for all other records added after it with the new cumulative total. 
    10.  newTotal = <Form_Link_Name>[ ID != 0 && Added_Time <= input.Added_Time].sum(Invoice_Amount);
    11.  input.Running_Total = newTotal;

    12.  for each update_total in <Form_Link_Name>[ ID != 0 && Added_Time > input.Added_Time]
    13.  {
    14.  update_total.Running_Total=newTotal;
    15.  update_total.Running_Total=newTotal + update_total.Invoice_Amount;
    16.  newTotal = newTotal + update_total.Invoice_Amount;
    17.  }
    18. }
  4. Create another workflow to execute on the On Validation of Form Deletion and select the record event as Deleted. This workflow updates the running total for all other records added after the deleted record with the new cumulative total.

  5. Click Add New Action and add the following script to the Deluge editor.
  1. //When deleting a record, update the 'Running_Total' field for all other records added after it with the new cumulative total.
  2. for each update_total in <Form_Link_Name>[ID !=0 && Added_Time >= input.Added_Time]
  3. {
  4.  update_total.Running_Total=update_total.Running_Total - input.Invoice_Amount;
  5. }
You can also choose to hide/disable this auto-incrementing number field to prevent manual user entries. To hide this field:
  1. Create a workflow by selecting record event as Created or Edited and form event as Field rules.

  2. On the subsequent page, click Add New Action, choose Hide fields, set this action to run always, and select the Running Total field.

See how it works


  1. Sum
  2. Currency

    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION






                          Quick Links Workflow Automation Data Collection
                          Web Forms Enterprise Begin Data Collection
                          Interactive Forms Workplace Data Collection App
                          Encrypted Forms Customer Service Accessible Forms
                          Digital Forms Marketing Forms for Small Business
                          HTML Forms Education Forms for Enterprise
                          Contact Forms E-commerce Forms for any business
                          Lead Generation Forms Healthcare Forms for Startups
                          Wordpress Forms Customer onboarding Order Forms for Small Business
                          No Code Forms Construction RSVP tool for holidays
                          Free Forms Travel
                          Prefill Forms Non-Profit

                          Intake Forms Legal
                          Mobile App
                          Form Designer HR
                          Mobile Forms
                          Card Forms Food Offline Forms
                          Assign Forms Photography
                          Mobile Forms Features
                          Translate Forms Real EstateKiosk in Mobile Forms
                          Electronic Forms

                          Notification Emails for Forms Alternatives
                          Holiday Forms Google Forms alternative 
                          Form to PDF Jotform alternative





                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                              • Related Articles

                                                                                                              • FAQs:​ Create Form

                                                                                                                This page covers creating forms and utilizing templates to import and integrate data sources, allowing you to duplicate forms effortlessly and integrate with other services seamlessly. How do I create a form from scratch? To create a form from ...
                                                                                                              • Create form from scratch

                                                                                                                Click the Add New icon displayed at the top of the Design page: Select Form , as shown below. If you're creating the first form in your app, you will be taken directly to step three. Select Blank . Enter a name for your form, then click Create Form. ...
                                                                                                              • FAQs: Components of Form Builder

                                                                                                                This page covers essential insights about Zoho Creator, a dynamic form builder, including how to seamlessly add, delete, and rearrange fields using the intuitive field palette, along with in-depth customizations in field properties. What is the form ...
                                                                                                              • Dynamic help text while filling a form

                                                                                                                Requirement   Display tooltips for fields and dynamic help texts for picklist (radio or drop-down) choices. Use Case   The careers page on a salon website contains a form listing the current openings for stylists. A dynamic text displays the ...
                                                                                                              • FAQs: Form Buttons

                                                                                                                This page covers about the functionality, customization, and optimization of form buttons in Zoho Creator, answering key questions and providing insights for enhancing user experience. What are form buttons in Zoho Creator? Form buttons in Zoho ...
                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources