Artisan SVG > Math Helpers (math-helpers) (calculator-1)
Artisan SVG > Math Helpers (math-helpers) (calculator-1)

Math Helper

The Math Helper interacts with numbers and list of numbers


The Math Helper connector allows you to interact with numbers and list of numbers.

'Add' and 'subtract' example

In this example we'll show how you to use the add and subtract operations for the math helper. In our example we will be using test data from a spreadsheet stored in Google Sheets. We're going to find out the total value by adding to or subtracting from a total, depending on the type, and then we'll send a Slack message with the total.

Here's what our final workflow will look like.

Here's the example spreadsheet we'll be using.

Step 1 - Retrieve Data

First we need to get our data from Google Sheets. Use the Google sheets connector and select the get rows data operation. Select the spreadsheet and worksheet that contains your data.

Step 2 - Loop Through Data

Next we need to loop through the rows we've just retrieved so that we can handle each entry separately. We'll use the loop connector for this with the loop list operation.

Our entries contain two types, gain and loss. For the gains we want to add to the total and for the loss we want to subtract from the total. Here's what will happen for each entry in our loop.

Step 3 - Branch Connector

Inside of the loop we need to first add a branch connector to decide weather or not we'll be subtracting or adding to the total which will depend on the type. We do that by setting the value to test to the cell in our loop that contains the type of entry. One branch to handle loss and one to handle gain. Here's how the properties panel will look for the branch connector.

Step 4 - Retrieve Total

For each branch we will set up very similar steps. First step is to get the total that we're working with. We need to set the default value to 0 so that on our first run, before we've set any value, it will return 0.

Step 5 - Math Helper Add / Subtract

Here's where we use our math helper. Depending on the branch (loss/ gain) we'll use either the subtract or add operation. In our loss branch we'll set the operation to loss and our first value will be set to the return of our data storage get value operation. The second value will be the 'value' column in our entry.

Step 6 - Store Result

Now all we need to do is store the result of our math helper so that we can use it later once we've run through every row in the spreadsheet.

Step 7 - Retrieve Total / Send Message

We first need to retrieve the total that we've been altering and then send that total via Slack.

We can retrieve our total by using a data storage connector with the get value operation.

Then we can use that number in our slack message.