Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Awesome thank you! That JavaScript was exactly what I needed!