Currency field sum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RSGRG
    Member
    • Feb 2019
    • 72

    Currency field sum

    I have several currency fields in a form. Now I would like to have a sum field, which shows all currency fields from the form calculated together. Which field type do I have to choose and what do I have to set?
  • DEN
    Senior Member
    • Apr 2021
    • 106

    #2
    Hello,

    Create the field any numeric type and write the desired formula in it.

    entity\sumRelated
    entity\sumRelated(LINK, FIELD, [FILTER])

    Sums related records by a specified FIELD with an optional FILTER.

    Example:
    entity\sumRelated('opportunities', 'amountConverted', 'won')

    More detail about formula here:

    Comment

    • RSGRG
      Member
      • Feb 2019
      • 72

      #3
      Many Thanks. I have now understood that, see screenshots. I have 5 currency fields in my form. Therefore I wrote 5 script formulas in the corresponding entity. Now I still need an output field where the total of these 5 currency fields is displayed. What do I have to set in this currency field or solve with a script so that the total amount is displayed there?

      Comment

      • DEN
        Senior Member
        • Apr 2021
        • 106

        #4
        Hello,

        I think perfect to use field "Description" where was display sum of all your field.

        For example:
        totalGiftsValue = entity\sumRelated('opportunity', 'opportunity.giftAmount');


        A similar question has already been met on the forum:
        https://forum.espocrm.com/forum/gene...r-entity-field
        https://forum.espocrm.com/forum/general/62829-calculate-sum-value-in-opportunities
        Last edited by DEN; 05-10-2021, 01:46 PM.

        Comment

        • RSGRG
          Member
          • Feb 2019
          • 72

          #5
          Thanks, but I don't understand exactly what to do. I don't want a sum of different projects, but a sum of a project with several parts. I have a project form, there are five currency fields listed. Then I created another currency field, in this field the amounts from the five fields mentioned above should automatically be output as a total. Perhaps the picture illustrates a little more precisely what I am imagining.

          Comment

          • DEN
            Senior Member
            • Apr 2021
            • 106

            #6
            Why you don't use a reports?

            There is just the function you need.
            You can try to do by analogy.

            Comment


            • RSGRG
              RSGRG commented
              Editing a comment
              Reports are only good for projects. But I have several project phases with individual prices per project and I want to show these as a total.
          • esforim
            Active Community Member
            • Jan 2020
            • 2204

            #7
            Are those 5 individual field with field name? You can just use a + sum formula if it is.

            Comment


            • RSGRG
              RSGRG commented
              Editing a comment
              Yes, there are 5 individual fields (Amount, amount1, amount2, amount3, amount4). For these 5 fields I need a field with the total.

              How do I do that with the + sum formula?

            • esforim
              esforim commented
              Editing a comment
              I believe it just something like this:
              For example

              totalamount=amount1+amount2+amount3+amount4

              or
              amount=amount1+amount2+amount3+amount4
              Last edited by esforim; 05-12-2021, 10:49 AM.
          • RSGRG
            Member
            • Feb 2019
            • 72

            #8
            Thanks espcrm, it worked wonderfully. Thread can be closed.

            Comment

            Working...