Announcement

Collapse
No announcement yet.

Please guide me: calculating numbers with formula (division, multiplication)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Please guide me: calculating numbers with formula (division, multiplication)

    Advanced Pack 2.5.14
    EspoCRM Version 5.9.3

    Hello!

    I am just starting to work with custom number fields in Espo. I did read https://docs.espocrm.com/administrat...titysumrelated but I am not quite sure what to do.

    The formula I need:

    field2 = field1 / field3 * field4
    or
    field2 = 4,0 / 70 * 30

    Result should be:

    field2 = 1,71

    Please let me know how I can write that as a code in Entity Manager/Formula!

    Thank you

  • #2
    should work like this:

    field2 = (4,0/70)*30;

    don`t forget the semikolon at the end. Sometimes the formulas are a bit tricky and you have to do a lot of trial and error, because there are no examples for each and every case. But it is nearly everything possible.

    And a general tip: Use as much field names as possible, not absolute values. That means, that the values should be in other fields. This way you avoid changing the formulas whenever a value changes.

    Comment


    • #3
      I see no issue with the code, only one thing that might concern me is your "4,0".

      Here is the formula I use to calculate Annual wage.
      Code:
      /*calculate annual wages if working throughout 52 weeks*/
      annual=gross*52;
      incomeAddAnnual=incomeAdd*52;
      /*calculate total income if there is additional income + 52 weeks working*/
      incomeTotal=annual+incomeAdd;
      Can you try a simple formula first to see if your Formula is working?

      for example:

      field2=4*30

      Then bit more difficult:
      field2=4.0*30

      (I don't think 4,0 will work, our country use 4,000.00 instead of 4.000,00)

      Then if it is working then you can slowly change it till you are confident:

      field2=field1*30;
      field3=field1/70;

      --
      Also note that your field name is CaseSensitive. If field name is fieldName it should be type like that and not like this "fieldname" or this "FieldName"
      Check out my thread for more reference of using Formula: https://forum.espocrm.com/forum/gene...crm-and-design
      Last edited by espcrm; 09-30-2020, 07:07 AM.

      Comment


      • #4
        Thank you very much for your advice.

        I tested step by step and ended out with this result:

        Comment


        • shalmaxb
          shalmaxb commented
          Editing a comment
          Was the result, what you wanted?

        • espcrm
          espcrm commented
          Editing a comment
          Very nice, good job. I like how you wrote those red text. Otherwise I ignore just get confused since it is a foreign language (field name).

      • #5
        @ shalmaxb:

        Yes, exactly what I wanted. Thanks so much!

        Comment

        Working...
        X