Please don't mind the tagging as the issue I am into is critical to my requirement.
Sample data and workbook attached.
I have Month, Day, Inventoryadded/deleted, Stock in Inventory columns in my database.
I want to show the running sum of the inventory based on a parameter.
Values in the Inventory added/deleted column are cr,db and NA. cr means credited, db - debited and NA means no change in status.
If the value is cr then stock should get added to the previous running total, if value is db then it should get subtracted from the previous value, if value is NA then it should show previous value. I tried and was able to achieve this.
I am pasting the formula here :
IF FIRST()=0 then sum([Stock in Inventory]) else
IF ATTR([Inventory added/deleted])='cr'
then PREVIOUS_VALUE(RUNNING_SUM(SUM([Stock in Inventory])))+SUM([Stock in Inventory])
elseif ATTR([Inventory added/deleted])='db'
then PREVIOUS_VALUE(RUNNING_SUM(SUM([Stock in Inventory])))-SUM([Stock in Inventory])
elseif ATTR([Inventory added/deleted])='NA'
then PREVIOUS_VALUE(RUNNING_SUM(SUM([Stock in Inventory])))
So far no problem. As soon as I proceed to the next step, I start facing problems.Let me explain what should be the next steps :
Now I want a parameter where if the user selects Month=February then the view should show running sum of the inventory on the last day of that month. In my case the output should be 2100(28th feb).
When I am capturing the parameter in my calc field then it is showing me the stock Inventory's cr,db or NA value for that day. Tableau starts calculating the running total from 0 for the filtered rows.
Hope I have explained the situation in detail.
Message was edited by: Ashish Verma