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


        Create. Review. Publish.

        Write, edit, collaborate on, and publish documents to different content management platforms.

        Get Started Now


          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 LinksWorkflow AutomationData Collection
                                Web FormsEnterpriseOnline Data Collection Tool
                                Embeddable FormsBankingBegin Data Collection
                                Interactive FormsWorkplaceData Collection App
                                CRM FormsCustomer ServiceAccessible Forms
                                Digital FormsMarketingForms for Small Business
                                HTML FormsEducationForms for Enterprise
                                Contact FormsE-commerceForms for any business
                                Lead Generation FormsHealthcareForms for Startups
                                Wordpress FormsCustomer onboardingForms for Small Business
                                No Code FormsConstructionRSVP tool for holidays
                                Free FormsTravelFeatures for Order Forms
                                Prefill FormsNon-Profit

                                Intake FormsLegal
                                Mobile App
                                Form DesignerHR
                                Mobile Forms
                                Card FormsFoodOffline Forms
                                Assign FormsPhotographyMobile Forms Features
                                Translate FormsReal EstateKiosk in Mobile Forms
                                Electronic Forms
                                Drag & drop form builder

                                Notification Emails for FormsAlternativesSecurity & Compliance
                                Holiday FormsGoogle Forms alternative GDPR
                                Form to PDFJotform alternativeHIPAA Forms
                                Email FormsFormstack alternativeEncrypted Forms

                                Wufoo alternativeSecure Forms

                                TypeformWCAG

                                  Zoho FSM Video Tutorials


                                        All-in-one knowledge management and training platform for your employees and customers.

                                                  Create. Review. Publish.

                                                  Write, edit, collaborate on, and publish documents to different content management platforms.

                                                  Get Started Now




                                                                    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


                                                                          • Desk Community Learning Series


                                                                          • Digest


                                                                          • Functions


                                                                          • Meetups


                                                                          • Kbase


                                                                          • Resources


                                                                          • Glossary


                                                                          • Desk Marketplace


                                                                          • MVP Corner


                                                                          • Word of the Day


                                                                          • Ask the Experts


                                                                            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 Demo

                                                                                                              Get a personalized demo or POC

                                                                                                              REGISTER NOW


                                                                                                                Design. Discuss. Deliver.

                                                                                                                Create visually engaging stories with Zoho Show.

                                                                                                                Get Started Now








                                                                                                                                    • Related Articles

                                                                                                                                    • Configuring notification actions for form workflows

                                                                                                                                      What does this page cover Learn about the notification actions in form workflows and how to configure them to send alerts via email, SMS, push notifications, display success messages, or redirect users to a URL. Before proceeding, ensure you have a ...
                                                                                                                                    • Configuring data access actions for form workflows

                                                                                                                                      What does this page cover Learn how to configure data access actions in Zoho Creator form workflows to add a new record, modify or delete an existing record in any form in your application. Before proceeding, ensure you have a comprehensive ...
                                                                                                                                    • Form workflow actions

                                                                                                                                      What does this page cover Learn about the various actions available in form workflows and how to configure them effectively. Before proceeding, ensure you have a comprehensive understanding of form workflows and how to create them. Availability ...
                                                                                                                                    • Configuring field rules for form workflows

                                                                                                                                      What does this page cover Learn about the actions that can be configured in field rules of form workflows to control field behavior, such as showing, hiding, enabling, disabling, or setting field values. Before proceeding, ensure you have a ...
                                                                                                                                    • 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 ...
                                                                                                                                      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