Best answer

Sum from line items

  • 20 December 2022
  • 4 replies
  • 1475 views

I have a zap getting all the records from salesforce meeting some conditions. I´d like to sum the amount arising from one field in those records. I´ve been able to capture the different lines with formatter and spreadsheet-style formula but It seems I can´t sum the output from my previous step

tried several options but none of them have worked. Any suggestion?

icon

Best answer by Danvers 20 December 2022, 10:02

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +12

Hi @David Carballas!

My guess is that you’ve been having trouble because the output is in line-item format. In Zap editor, it’ll look like both numbers are separated by commas but in the output you shared, you can see that the numbers are in two different fields. 

If you convert the line-item to text, you’ll then be able to use that in a Spreadsheet style formula step. 

First, you need to convert the field from line item to text. To do that use Formatter by Zapier, select Utilities and then line-item to text. The output of that step will give you one field: both numbers separated by a comma. It’ll look the same in the Zap editor as before, but if you look at the output if the Formatter step you’ll see that they are now both in the same field. 

You can then use the output of that Formatter step in a Spreadsheet-style formula step to add the two numbers together using a formula that looks like this: sum(9154.7,8292.38)

 

​I hope that helps, please us me know if you have any questions!

Userlevel 7
Badge +8

Hi @David Carballas ,

 

I think we need more context to be able to help you.

 

If I understand correctly, the Trigger is returning more than 1 record from Saleforce and you want to sum up those values from different records, is that correct?

 

In this case you will need to use Looping by Zapier and Storage by Zapier to loop through the different line items, sum them up using a formatter, store the value, then loop again to add the next value. 
 

Another easier approach would be using Code step to sum the items up. (Depends on your use case)

Hi @David Carballas!

My guess is that you’ve been having trouble because the output is in line-item format. In Zap editor, it’ll look like both numbers are separated by commas but in the output you shared, you can see that the numbers are in two different fields. 

If you convert the line-item to text, you’ll then be able to use that in a Spreadsheet style formula step. 

First, you need to convert the field from line item to text. To do that use Formatter by Zapier, select Utilities and then line-item to text. The output of that step will give you one field: both numbers separated by a comma. It’ll look the same in the Zap editor as before, but if you look at the output if the Formatter step you’ll see that they are now both in the same field. 

You can then use the output of that Formatter step in a Spreadsheet-style formula step to add the two numbers together using a formula that looks like this: sum(9154.7,8292.38)

 

​I hope that helps, please us me know if you have any questions!

thanks for the repply. I´ve used your approach and fixed it. I have just a small comment, as I had 2 lines the output shows twice the math operation I was running

Any idea how to fix this?

Userlevel 7
Badge +12

Hi @David Carballas!

I’m glad that my suggestion worked for you 🙂

For your question about the output of the formula step, it would be helpful to see how the output of the line-item to text Formatter step and also a screenshot of the set up of the Spreadhseet style formula step - are you able to share those screenshots? Don’t forget to remove or obscure any personal or private information in any screenshot you share in the community (eg full name, email address, etc).

 

Thanks!