Performing calculations with values from Google Sheets

(Yun) #1

Having trouble trying to get the result in “Total” (multiplying one value with another in the same sheet).

Is there a way to do this?

(Kellsey Shaw) #2

Hi Yun,

You’d need to the user the Number service to perform calculations :slight_smile:

(Yun) #3

Hi Kellsey,

Thank you for your prompt reply.

However, I’m still not getting the result.

Is there something wrong with my code?

 Total: $ math.eval('{{ask_quantity.parsed_answer}} * {{connect_to_stocks.results_+_gsx:price    {{ask_items.parsed_answer}}');
(Kellsey Shaw) #4

Hi Yun,

You would need to use the calculation in the Numbers service and then use the output of that service in your message :thumbsup:

(Yun) #5

Hi Kellsey,

Well noted on your reply.

However, the “Number” action failed to execute as according to the logs: “The request failed because something unexpected had happened.”.

(Kellsey Shaw) #6

Hi Yun,

I believe that it may be the docs that need to be updated. If you remove math.eval and the single quotes, the calculation will work :slight_smile:

(Yun) #7

Hi Kellsey,

It works! Thank you very much.

But the this Calculate action is not executing when I replaced the variables with a Collection Output.

(Kellsey Shaw) #8

HI Yun,

I’ve tested this and it seems to be working fine for me.

Are you seeing an error in your logs?