Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
I'm having trouble getting the right script to calculate my stock value per product per day from all the past days till this day. Plus I must be able to select a day in the past and the correct stock value of that day must be shown in a text box and I need to store the data in a table.
I have a lot of different transactions, so on a single day there can be many mutations, but basically there is only one field for stock value (Stock_value). My data looks like this:
Stock_value | Date | Units | Item_No | Warehouse | Product_Version |
-1.309 | 31-12-2023 | -29 | 602483 | A | 1 |
-3.149 | 31-12-2023 | 0 | 602483 | A | 1 |
-326 | 31-12-2023 | -2 | 602483 | A | 2 |
- | 31-12-2023 | 0 | 602483 | A | 1 |
- | 31-12-2023 | 0 | 602483 | A | 1 |
-20 | 31-12-2023 | 0 | 602483 | A | 1 |
90 | 31-12-2023 | 2 | 602483 | B | 2 |
90 | 31-12-2023 | 2 | 602483 | A | 1 |
677 | 31-12-2023 | 15 | 602483 | A | 3 |
-1.286 | 29-12-2023 | -2 | 602483 | A | 1 |
- | 29-12-2023 | 0 | 602483 | A | 2 |
- | 29-12-2023 | 0 | 602483 | A | 2 |
1.194 | 29-12-2023 | 0 | 602483 | A | 2 |
-2.571 | 28-12-2023 | -4 | 602483 | A | 1 |
- | 28-12-2023 | 0 | 602483 | A | 1 |
- | 28-12-2023 | 0 | 602483 | A | 1 |
2.389 | 28-12-2023 | 0 | 602483 | A | 1 |
- | 28-12-2023 | 0 | 602483 | A | 2 |
- | 28-12-2023 | 0 | 602483 | A | 2 |
And my script is:
Try with
// read your data
// cumulate when the key changes (item, warehouse, prod vers; exclude the date)