This might be simple but I am breaking my head. I want the calculation that is done on the chart to be implemented in the script.
Open Inventory = Previous Month Closing Inventory(Expression : Above(Closing Inventory))
Closing Inventory = Open Inventory + In Sales - Out Sales
This is easy in the chart as I can use the column labels and get it done but seems tricky in the script.
Reason behind needed in the script: If nothing is selected, all good. But if I select a month, the calculation starts for the selected month. Open Inventory can't take the previous month Closing Inventory. So, if it is done in the script, everything will be pre-calculated.
I tried to be detail to my best . Let me know if any questions and thanks in advance.
I think you can achieve the desired output with peek() -script function. Just need to use order by clause in order to retrieve the data from prev yearmonth as you desired. Also make sure that you have correct granularity in your script table.
Edit: Alternatively you may ignore the selection in chart expression with set analysis. This way you always have previous month available even though user has made a selection to a specific month.
Did Taoufiq's post and example QVW get you what you needed? If so, do not forget to return to your thread and on his post, use the Accept as Solution button to give him credit for the assistance and let other Members know that worked for your use case. If you did something different, consider posting that and mark it, and if you are still working on things, leave an update on what you need.
To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question. I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.