Summing Variables: Summing 28 Variables with a Function


Good morning everyone,

I have 28 variables that I would like to add together to get a total amount.  Would anyone know how to do that with a Function?  Otherwise, I could go the long way and perform "Do Calculation[s]" functions multiple times.

Thank you for your thoughts and time.

 


2 replies

Userlevel 6
Badge +16

Hi @Underdog 


 


1. Use a Web Service such as math.js web service



The site has some caveat - The duration per evaluation of this free service is limited to 10 seconds, with a maximum of 10,000 requests per day.


 


Let's say we want to calculate "1+2+3+4+5+6+7+8+9+10"


TIP: There is a Try it where you can enter your math expression and it will generate the URL



TIP: the '+' symbol converts to '%2B


 


STEP 1: Generate the Math Expression using the Build String action.



Put all the 28 values. Save to a strExpression


 


STEP 2: Replace '+' symbol with '%2B' using Replace Substring in String action.



Step 3: Configure the Call HTTP Web Service action



Address: http://api.mathjs.org/v4/?expr={Variable:strExpression} 


For this example, I used http://api.mathjs.org/v4/?expr=1%2B2%2B3%2B4%2B5%2B6


which is 1+2+3+4+5+6


 


Step 4: Run


If everything is configured correctly, it returns (using the Log)


Log to History 


Response Content returns 21


 


 


Cheers

Userlevel 5
Badge +20

Please remember to mark posts as solutions if your question was solved! 

Reply