Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello !
I have an input field initialized with zero.
I want to set a value on it based on a expression of a chart, and only then the user can adjust it.
I need that because the inicial calculation of this field is based on a sum of selected items.
This what I have:
Inventory:
Product | Stock |
---|---|
P1 | 10 |
P2 | 3 |
P3 | 9 |
P4 | 11 |
Sells History:
Product | Month | Quantity |
---|---|---|
P1 | 1 | 3 |
P1 | 2 | 4 |
P1 | 3 | 2 |
P2 | 4 | 3 |
P3 | 1 | 5 |
P3 | 2 | 4 |
P4 | 1 | 4 |
P4 | 2 | 3 |
P4 | 3 | 6 |
P4 | 4 | 2 |
Demand:
Product | Sum(Quantity) | Allocated |
---|---|---|
P1 | 7 | 7 |
P2 | 4 | 3 |
P3 | 9 | 9 |
P4 | 7 | 7 |
My inputfield is "Allocated". In this example, I selected the Months 1 and 2.
The initial expression for it is:
If(Sum(Stock) >= Sum(Quantity), Sum(Quantity), Sum(Stock))
For the Product P1, the "initial value" of the input field "Allocated" is 7 (because the Sum(Quantity) is based on Months 1 and 2).
If I change the selection of the Months, the initial value of the input field "Allocated" should change.
How can I achieve this ?
Thanks!!
Josué
I don't really understand the requirement clearly, would you be able to share the output you are expecting based on few different selections?
Let's consider that the value of Sum(Stock) of Product P1 is 8 (Ignore the first table).
If I select the Months 1 and 2, the Sum(Quantity) of product P1 is 7 (see second table).
So, following the expression for the initial value of "Allocated" of Product P1, its value should be 7.
If I select Months 1, 2 an 3, the Sum(Quantity) of Product P1 is 9 (3 + 4 + 2).
With that, the initial value of "Allocated" should be 8 (according to the formula expression).
I think your formula is doing that. Look at P4 Product
Picking stock, since Sum(Stock) is lower when no selection is made
.
Picking Quanitity, since Sum(Stock) is higher now based on Month 1 and 2 selected
Isn't that what you want?
Yes, but I need that inside an input field.
My idea (actually the client's idea) is the following:
The user select a couple of months, then we will have an "initial" value for "Allocated" (based on the expression).
Then, he can adjust this value manually.
As the expression is based on selections, I cannot set an initial value for this field using the load scripts.