Skip to main content

I have an operation where I’d like to do some math with formatter before placing the data in a spreadsheet. The only problem is the number of output items from the previous formatter step can vary quite a bit. I can easily use outputs 1-5 in the screenshot below, but when another trigger comes through that produces more than 5 output items it would only add up to 5. Is there anyway to to have it add all output items or possibly another way to accomplish what I’m trying to do?

 

Thanks! I’m usually good at finding answers myself but this simple issue has me stumped.

 

Hey ​@Asterisk,

Try using Formatter → Numbers → Spreadsheet-Style Formula action to do the SUM().

 


Map the output text from the previous formatter inside (). Hope it helps!


Thank you, it still produces individual output items though as opposed to a sum unfortunately. I was able to solve it with javascript

 

// Get the input string (or empty fallback)

const raw = inputData.numbers || "";

 

// Split into numbers, clean, and filter out non-numeric values

const nums = raw

.split(',')

.map(n => parseFloat(n.trim()))

.filter(n => !isNaN(n));

 

// If no valid numbers found, return 0 safely

const sum = nums.length > 0 ? nums.reduce((a, b) => a + b, 0) : 0;

 

return { sum };


Hey ​@Asterisk,

It will produce a sum only if you will pass the correct input in it. Nice you were able to solve it with Javascript but advantage of Formatter over Code is it doesn’t use any tasks in Zapier. Hope it helps!


Oh good to know, I’ll give it another shot. Thanks ​@Sparsh from Automation Jinn !