Property Calculator, parenthesis doesn't work with operations

I was creating a property calculation to sum all properties from related objects, that works but the total represent only the 80% and after the sum of relatives I need to add manually the 20% this is just becaus an intenal procedure and needs to be like that.

the property is "MC_Ponderado Total"

I was trying this in the operation giving me the result of 80, that is correct for the sum of relatives

{Actividades.ForEach()]+{Ponderacion}

this work to sum all Ponderation values from all relatives that should count 80 because the procedure, but to the total I need to add 20 to complete the 100% needed to be viewed in the metadata card.

I've tried this but does not work giving a null result

({Actividades.ForEach()]+{Ponderacion})+20

Trying This without parenthesis

{Actividades.ForEach()]+{Ponderacion}+20

Add 20 to each relative making a sum grater than 100%

How could this be solved?

Parents
  • Hi,

    Parenthesis does not work, because problem is not related to calculation itself, but foreach functionality and how it build string that is counted. Foreach makes rest of the sentence loop for every single "Actividades". Because of that +20 is added for every "Actividades" object, and parenthesis has no effect for that.

    There is couple ways to fix this:

    1. Set fixed part before the loop:

    "20{actividades.foreach()}+..."

    2. Add 20 separately:

    There can be another rule below this, that will add 20 to end result:

    There is also "Next()" placeholder which ends looping in selected point. At least earlier it had some side effects and Property Calculator did not support it. I am not sure what is current situation.

  • Finally because adding 20 depends on another metadata condition the solucion with your help works this way:

    Thanks a lot!

    so for general cases is just the sum of all (For Each) and in one case needs to be added 20 to complete the 100%

Reply Children
  • Your original expression with foreach generates:
    "+ {value 1} + {value 2} + {value 3} + ..."
    If you add 20 to beginning, you will get:
    "20 + {value 1} + ..." which should have wanted impact.

    And about grouping level. If you add conditions to grouping level, they are used for both rules. You can be sure that +20 is added every single time the calculation is done. Your solution works as well, but now you need remember to modify both conditions, when any changes are done.