How to make sliders connected and constrained to a maximum value

HI I’d like to make the sliders connected and constrained to a maximum value.

e.g.: I have 5 categories and the user should be able to adjust their values but in the end the sum of the values should be 100%

Cat. A = 0.2
Cat. B = 0.3
Cat. C = 0.1
Cat. D = 0.2
Cat. E = 0.2

How can I do this?

Hi Francesco,

The interface builder doesn’t have any capabilities to have dynamic constraints or validation on the slidebars without custom HTML/Javascript coding.

You can do this however in two different ways.

The simplest is to handle it in the model. Let the user enter values that total to more than 100%, then normalize it in the model to sum to 100%.

Add these equations to the model. (In whatever language you are using).

Cat A = .2
Cat B = .2
Cat C = .2
Cat D = .2
Cat E = .2

Total Cat = Cat A + Cat B + Cat C + Cat D + Cat E

Actual A = Cat A / Total Cat
Actual B = Cat B / Total Cat
Actual C = Cat C / Total Cat
Actual D = Cat D / Total Cat
Actual E = Cat E / Total Cat

The “Cat” variables are your inputs. The model will then normalize the “Actual” values so they total to 1. Then use the “Actual” values elsewhere in your model.

An alternate approach would be handle this with validation in the sim interface. This will require you to create a JavaScript function and edit the HTML directly. It should total up the inputs, and when you submit the decision form will display an error and refuse to submit if the total isn’t 100.

WILL

1 Like

Thanks! I’ll try it right away