Skip to main content
adobe5505
Known Participant
Feb 3, 2021 1:12 AM UTC
Question

Expression Advanced Action

Hello, I have set up an Expression Advanced Action to display the sum of 2 variables and it works perfectly. I now want to extend that to calculating the sum of 9 variables total. Is there a way to include all the variables in one row such as V_Sum= V_1+V_2+V_3+V_4 etc., or do I need to set up and action another way such as calculating the sums of the different actions?

    This topic is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    RodWard
    Community Expert
    Community Expert
    Feb 3, 2021 1:23 AM UTC

    You just add more line items that are Expression actions underneath the current one.  Each line begins with the total from the previous line.  The trick here is that you only add ONE of the variables to V_Sum at a time.

     

    So it looks like this:

    V_Sum = V_Sum + V_1

    V_Sum = V_Sum + V_2

    V_Sum = V_Sum + V_3

    etc.

    Translate
    Stagprime2687219
    Legend
    Feb 3, 2021 1:04 PM UTC

    Another option is to pick Execute JavaScript instead of Expression and craft this a little more as you were thinking of it.
    I personally find this easier/faster than clicking out nine expression actions.

    In the JavaScript window you would type this particular calculation out exactly as you did in your question.

    Just don't forget the semi-colon on the end.

    V_Sum=V_1+V_2+V_3+V_4+V_5+V_6+V_7+V_8+V_9;

     

    Translate
    adobe5505
    adobe5505Author
    Known Participant
    Feb 3, 2021 6:53 PM UTC

    Awesome thank you! That JavaScript was exactly what I needed! 

    Translate