Jump to content
We've recently updated our Privacy Statement, available here. ×

Adding Multiple Cumulative Sum


John
Go to solution Solved by Olivier Keugue Tadaa,

Recommended Posts

Hi!

Would it be possible to add multiple cumulative sum expressions?  I want to get the delta of the following expression

1st  Expression: SN(Sum([New_Backlog]) OVER (AllPrevious([Axis.Columns])),0)

2nd Expression: SN(Sum([New_Early]) OVER (AllPrevious([Axis.Columns])),0)

3rd Expression: Sum([New_Commit Qty]) Then Sum([Value]) OVER (AllPrevious([Axis.Columns])) as [Cumm Commit]

4th Expression: Sum([FGOUT])/Count([ExtractDate]) THEN Sum([Value]) OVER (AllPrevious([Axis.Columns])) as [Cumm Out]

Delta Forumul

3rd Expression + 2nd Expression - 1st Expression - 4th Expression

image.png.5cfa97a909ac0097f4882883f60ff6ff.png

 

 

 

 

 

 

Link to comment
Share on other sites

Hi John

The answer to your question  is YES however you  will put the delta into one large expression like this one:
SN(Sum([New_Backlog]) OVER (AllPrevious([Axis.Columns])),0) +
SN(Sum([New_Early]) OVER (AllPrevious([Axis.Columns])),0) -
Sum([New_Commit Qty]) Then Sum([Value]) OVER (AllPrevious([Axis.Columns])) -
Sum([FGOUT])/Count([ExtractDate]) THEN Sum([Value]) OVER (AllPrevious([Axis.Columns]))
as [Delta]


If your question is about if you can first define the first 4 expressions and re-use them in the delta (like this 3rd Expression + 2nd Expression - 1st Expression - 4th Expression), then the answer is NO (at least for customs expressions). 

I hope this helps.

Link to comment
Share on other sites

Hi John,

This typically means that the [New_Commit Qty] column doesn't exist in the dataset.
What is the error message? You should have a red exclamation mark icon at the right end of the formula, explaining what the error is. Also, can you verify if this column is available in your data table (used for the formula)?

Kind regards,

David

Link to comment
Share on other sites

Hi John,

What I can see in your formulas, is that all working constructs with THEN is preceded by a division. For instance, Sum([FGOUT])/Count([ExtractDate]) THEN...
In the one that doesn't work, there is no such division. That could be a possible problem.

But you also defined a formula twice as [Delta], that may also be a problem as Spotfire doesn't know which one should be taken into account as [Delta].

Could you check both?

Kind regards,

David

Link to comment
Share on other sites

Hi David,

I already rename the [Delta] and I still facing the same error. I did try to remove the 4th expression and it's working. can we use two THEN statements in an expression?

image.thumb.png.655b2be9045c3e311444078aa02d117a.png

 

Link to comment
Share on other sites

  • Solution
Posted (edited)

Hi John, sorry for my late reply.
Please use this one (I have removed the THEN since it is usually used for optimisation purpose or when you have in-db data source).


SN(Sum([New_Backlog]) OVER (AllPrevious([Axis.Columns])),0) + 
 SN(Sum([New_Early]) OVER (AllPrevious([Axis.Columns])),0) - 
Sum([New_Commit Qty]) OVER (AllPrevious([Axis.Columns])) - 
Sum([FGOUT]) / Count([ExtractDate]) OVER (AllPrevious([Axis.Columns])) as [delta]

It should work now

Or if you should use THEN,

Since after THEN you can only use Value (assuming it contains the previously calculated metrics),

and all calculations are made against the same OVER (AllPrevious([Axis.Columns]))

then you have this alternative expression with the same result, while keeping the benefits you had with the THEN

SN(Sum([New_Backlog]),0) + 
SN(Sum([New_Early]),0) - 
Sum([New_Commit Qty]) - 
Sum([FGOUT]) / Count([ExtractDate]))


THEN sum([Value])

OVER (AllPrevious([Axis.Columns]))

AS [delta]

Please let us know if it works for you

Edited by Olivier Keugue Tadaa
Link to comment
Share on other sites

Hi!

Regarding the Over Function, is it possible to do division on below two expressions to get the rate? 1st Expression/2nd Expression

1st Expression: SN(Sum([FGOUT]) / Count([FGOUT]),0) + SN(Sum([New_Early]),0) - SN(Sum([New_Backlog]),0)  - SN(Sum([New_Commit Qty]),0) THEN sum([Value]) OVER (AllPrevious([Axis.Columns])) as [Delta]

2nd Expression: Sum(-[New_Commit Qty]) as [Commit]

image.thumb.png.52e8403778211b77217317b883f972cb.png

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...