# Slider Variable PLUS a constant

Sep 26, 2016

Hi everyone.

I'm trying to create a variable from a slider and a constant number.

I can create a trigger that updates my new variable (TOTAL) that adds 20 to what ever number my slider is on.

For example - Slider =1, my TOTAL variable will read 21

At slider =2, TOTAL = 22 , etc

At some point, my TOTAL variable will never go down (if you're sliding back to 1).

How can I create this?

THANK YOU

###### 23 Replies

You need to add a trigger that resets the Total variable to zero and then make sure that this trigger is executed BEFORE the one(s) that calculate slider +constant.

Thanks Michael.

So I have varibles: Slider1, TOTAL.

I have placed the trigger before the calculation but I think I am missing something.  Do I create a third variable called CONSTANT?

I don't know why I'm having such a problem visualizing this.

At what point does the constant number of "20" get added to the value of Slider1?

It may be easier to help if you can share your .story file (or that one slide with the slider) here.

Thanks Michael!

Here is the attachment.  Basically, I want the slider variable (1-10) to add a constant number (20) and display as variable X in this example.

So when Slider is at 1 ; X is 21.

Slider is at 2; X is 22.

Slider is at 3 : X is at 23, and so on

I know what I did wrong.  I needed to set X to 20 when the slider moves.

and then second trigger will add the slider to X.

I feel silly figuring this out so late.

THANKS FOR YOUR HELP MICHAEL!!  You rock!

Walt Gill

I know what I did wrong.  I needed to set X to 20 when the slider moves.

and then second trigger will add the slider to X.

I feel silly figuring this out so late.

THANKS FOR YOUR HELP MICHAEL!!  You rock!

Hi Walt, great to hear that you figured it out. Good luck with your project!

Hi Walt and Michael.  I'm hoping one of you can help me.  I'm trying to do something similar to what you did, Walt.  Except I'm adding 15,000 when the slider moves up and want to subtract 15,000 if it moves back down the slider.  (The variable value increase by 15,000 at each step as slider is moved across.)

I have one trigger set:

When Slider moves (Slider 1)

The value increases correctly by 15,000 when slid across the slider.  However, when the slider is moved back down, it continues to add 15,000.

How do I get the variable to decrease by 15,000 if the slider is moved back?

Or should I configure my slider properties differently to achieve this same result?

Hi Victoria

how many steps on your slider and does it start at the beginning or mid point?

Can you set the start value of the slider to 1500, increment by 1500 and multiply it by 10 each time the slider changes?

Hi Wendy - there are 10 steps.  Starts at 0 and increments by 15,000 up to 150,000.

The point of the interaction is for the learner to select a dollar amount that is their guess/answer to a question (what is the estimated cost to hire an employee).  Then on the next slide the answer is revealed.

Hi Walt.  Thanks for the quick reply.

For this interaction it wouldn't make sense to set the start value to 1500.  In my response to Wendy, you'll see that the purpose of the slider and why that wouldn't make sense.

After submitting my question, I did set up an alternate slider with static amounts as states.  This works, but I had hoped to just have one text box (variable) show the changing amount as the learner moved the slider up and down the bar.

Yes!  That's it!  Thank you!

I've studied how you set that up.  To help me apply this again in the future when creating a slider interaction, can you help me understand the logic that makes this work?

On the Slide Tools Design tab:

1. Start: set to 0.  I'm guessing this Is Slider1 variable's set value.

2. End: set to 150.  Is this the end value of Slider1 variable (the ending valuing at the last step on the slider)?

3. Initial: set to 0.  From what I researched last week on sliders, it's my understanding this is the initial step or location where the slider starts. (just confirming)

4. Step: set to 15.  My understanding is this is the total number of steps.  How did you decide to use this number?  Is this based on the ending value 150?

5. I see that the first trigger sets the Cost variable to equal the value of Slider1 variable when the slider moves and the second variable multiplies the Cost variable by 1000 when the slide moves. I get that this is what changes the Cost value on screen.  However, I don't understand how it decreases when the slider is moved back down towards the start.

6. How can there be 15 steps and only 10 stops on the slider and it knows to display the appropriate value at each stop up to 150,000?

Thank you, again for your help with this.

Victoria :)

1. You are correct that the start is the variable's first value. In addition, when the timeline starts, the slider is set to the stop (location) that corresponds to that value. So if you move the slider, leave the slide, and return to it, the slider will return to the location where you left it.

2. Yes

3. Yes, unless the variable has changed as #1 describes.

4. Not exactly. The total number of values on a slider is the number of stops (locations). The step value is how far apart those stops are. It can be set from .01 to 150. If it could be set to 15,000 you would not have had a problem :) By setting the total distance the slider moves to 150, and setting the distance between stops to 15, I created 10 stops (well, 11 if you count 0).

5. Every time the slider moves, it completely replaces the variable attached to it. In this case, that is Slider1. That is a built in trigger that you don't see, but it does not add or subtract from the variable, it sets it to the value of the slider in its new position. The first trigger I wrote puts that value into Cost, and the second trigger multiplies Cost by 15000. The variable is constantly updated to the value of the slider. You can watch this by creating a text box on the screen. Inside it put "%Slider1%", without the ". It will show the value of the slider.

Don't hesitate to ask if you have other questions.

A very clever and simple solution, Walt. Now I have a similar, but perhaps more complicated question. How would you do the same sort of interaction using multiplication and division? I want to have a Total number of 30, and as the slider moves to the right, that number gets divided in half (up to 4 times). When the slider is moved back to the left though, I need those numbers to get multiplied or set back to their previous amounts.

That is step 1. The other part of this equation is, I want to have 3 sliders all affecting that total number of 30 in the same way.

Thanks for any help.

The first part is easy to do (unless I misunderstood what you are trying to do), see attached a quick example. I'm not sure about the second part though. Are you saying you want the AGGREGATE of the three sliders to influence the overall number?

Thanks for the quick reply and help, Michael. This is almost exactly what I was thinking for the logic, I just couldn't get all the way there. Thank you.

Yes, I am looking for the aggregate. All 3 sliders, functioning the same way, affecting that total number. So if you drag 1 slider 1 spot, and another slider 2 spots, it would take the total number down to 0.47, just as it did in your example with 1 slider.

Jon Bailey

Thanks for the quick reply and help, Michael. This is almost exactly what I was thinking for the logic, I just couldn't get all the way there. Thank you.

Yes, I am looking for the aggregate. All 3 sliders, functioning the same way, affecting that total number. So if you drag 1 slider 1 spot, and another slider 2 spots, it would take the total number down to 0.47, just as it did in your example with 1 slider.

Hm, that would work if the aggregate of the 3 slider positions is <=4. What should happen if all three sliders are all the way to the right?

It works as it should by just repeating those steps you laid out. If they are all to the right, you should get a very small number. Thanks again for the help.

I'm still not sure if that's what you're after, but have a look at the attached.

Yeah, you got it. Basically just repeating everything for the first slider for the other 2 sliders worked for my purposes. Thanks again.

That's good to hear. I guess I was overthinking it at first :-)