
1. Re: Question regarding running total
Daniel Vincent Oct 15, 2015 2:58 PM (in response to Shinichiro Murakami)If you just need to see Inventory then use this calc
WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0)

Runing_Total_Q.twbx 27.3 K


2. Re: Question regarding running total
Shinichiro Murakami Oct 15, 2015 3:15 PM (in response to Daniel Vincent)Thank you, Daniel
But the problem is I don't want to show Inventory with "less than 0" at any time.
Inventory should be always max(0, calculated result).
And Period 2's inventory = Max ( 0 ,Period 1's inventory + Period 2's Supply  Period 2's Demand )
Hope I explain what I need.
Thanks,
Shin

3. Re: Question regarding running total
Daniel Vincent Oct 15, 2015 3:24 PM (in response to Shinichiro Murakami) 
4. Re: Question regarding running total
Shinichiro Murakami Oct 15, 2015 3:28 PM (in response to Daniel Vincent) 
5. Re: Question regarding running total
Daniel Vincent Oct 15, 2015 3:55 PM (in response to Shinichiro Murakami)Okay....I think I covered all the bases but it's possible I missed something. Take a look and just let me know if its good or needs more tweaking.
IF (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0)) > 0 THEN (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0))
ELSEIF (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0)) < 0 AND (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0)) < 0 THEN 0
ELSE (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0))
END

Runing_Total_Q.twbx 35.1 K


6. Re: Question regarding running total
Shinichiro Murakami Oct 15, 2015 4:19 PM (in response to Daniel Vincent) 
7. Re: Question regarding running total
Daniel Vincent Oct 15, 2015 5:32 PM (in response to Shinichiro Murakami)You do realize your values for period 11 on is different between what you have in Tableau and Excel, right? Regardless, I did catch that last part where I needed to start over the count of inventory. My eyes might be crossed at this point so I'll probably take a break and come back to see if this is right or needs another go round...
IF INDEX()=1 THEN (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0))
ELSEIF (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0)) > 0 AND (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0)) < 0 THEN (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0))
ELSEIF (WINDOW_SUM(SUM([Supply]),FIRST(),0) WINDOW_SUM(SUM([Demand]),FIRST(),0)) < 0 AND (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0)) < 0 THEN 0
ELSEIF (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0)) > 0 AND ZN(LOOKUP(SUM([Supply]),1) LOOKUP(SUM([Demand]),1)) < 0 THEN (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0))
ELSEIF (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0)) > 0 AND ZN(LOOKUP(SUM([Supply]),1) LOOKUP(SUM([Demand]),1)) > 0 THEN (LOOKUP(SUM([Supply]),0) LOOKUP(SUM([Demand]),0)) + ZN(LOOKUP(SUM([Supply]),1) LOOKUP(SUM([Demand]),1))
END

Runing_Total.twbx 29.8 K


8. Re: Question regarding running total
Shinichiro Murakami Oct 15, 2015 8:13 PM (in response to Daniel Vincent) 
9. Re: Question regarding running total
Nasrin Ahmed Oct 15, 2015 11:43 PM (in response to Shinichiro Murakami)Use
max(PREVIOUS_VALUE(0)+[SupplyDemand],0)
P.S : for last 3 periods the value you provided in excel sheet 6 does not match with your jpg file

10. Re: Question regarding running total
Shinichiro Murakami Oct 16, 2015 12:10 AM (in response to Nasrin Ahmed)