# Set variable equal to sum of two other variables - Storyline 360

Jul 23, 2020

Sorry if this is covered somewhere, but I have not been able to find anything about the following:

I would like to set the value of a variable x equal to the sum of variables y and z. This would eliminate the need to create additional triggers anytime I want to increase the value of variable x.

Right now, I have the following:

When the user clicks Button 1
- Add value 20 to AT1
- Add value 20 to ATSum

When the user clicks Button 2:
- Add value 10 to AT2
- Add value 10 to ATSum

If I could set ATSum to keep a running total of the sum of AT1 and AT2, then I would not have to include the extra trigger for each button (I have 12 of these buttons.)

Thanks!

###### 6 Replies

There are a bunch of ways to do that. It depends on what else is going on, like are you just sitting on this page clicking the buttons?

Regardless, here is one way. Have your calculations run in an invisible layer. That way, you can reuse them by showing the right layer. No need to re-create for each of your buttons.

Here is an example of what it might look like.

https://360.articulate.com/review/content/e92ee5e0-48f5-4a86-ab6e-607b2f8ea22a/review

See if this is what you wanted and if so I can help you with the easiest way to implement.

Russ

This is the file. I hope it helps.

Russ

Thanks so much for creating this, Russ. Yes, we're just sitting on one slide clicking the buttons. I understand the logic of your solution, but I'm thinking that having the hidden layers might be more complex than just including the additional ATSum trigger on each button. It appears that I would have to create a separate layer for each of the 12 buttons and set up the logic for each. At this point, I think just keeping the ATSum trigger on each button would be easier.

I also see that we still have to add the value to each variable (ATx and ATSum). I was hoping there is a mathematical way to have a variable value created by adding two variable values, but I don't believe that is a feature.

Anyway, thanks again for taking the time to help out. I appreciate it!