dbTalk Databases Forums  

Cumulative Sum

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Cumulative Sum in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Clint
 
Posts: n/a

Default Cumulative Sum - 12-04-2005 , 11:59 PM






Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint



Reply With Quote
  #2  
Old   
MC
 
Posts: n/a

Default Re: Cumulative Sum - 12-05-2005 , 01:12 AM






Check for the ytd() function. It would be something like

sum(ytd([Time].[Calendar]), [Measures].[Sales])

Offcourse, to get results you would have to include time dimension in the
query.


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote

Quote:
Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint




Reply With Quote
  #3  
Old   
Clint
 
Posts: n/a

Default Re: Cumulative Sum - 12-05-2005 , 04:04 PM



Hmm..

YTD isnt quite what I am after...

Here is an example of what I have currently..

Using the Foodmart 2000 cube (SALES)

WITH MEMBER Measures.[Cumulative Sales] AS 'SUM( HEAD( ORDER(
{[Time].Siblings}, [Measures].[Unit Sales], BDESC ) AS OrderedSiblings,
RANK( [Time], OrderedSiblings ) ), [Measures].[Unit Sales] )'

SELECT

ORDER( DESCENDANTS( [Time].&[1997] ), [Measures].[Unit Sales], BDESC ) ON
COLUMNS,

{[Measures].[Unit Sales], [Measures].[Cumulative Sales]} ON ROWS

FROM [Sales]



Basically what I want to see on Columns... are the months of 1997... and
each month is cumulative..

The above code kind of works, but doesnt focus purely on month. I need some
help on that.



Thanks!!

"MC" <marko_culo#@#yahoo#.#com#> wrote

Quote:
Check for the ytd() function. It would be something like

sum(ytd([Time].[Calendar]), [Measures].[Sales])

Offcourse, to get results you would have to include time dimension in the
query.


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:upjoUEW%23FHA.2664 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint






Reply With Quote
  #4  
Old   
MC
 
Posts: n/a

Default Re: Cumulative Sum - 12-06-2005 , 02:18 AM



Could you explain why something like doesnt work:

WITH MEMBER
[measures].[cumulative sales]
as
'
sum(ytd([Time].[Calendar]), [Measures].[Sales])
'

select
[Time].[Calendar].[Month].members, --- put here descendants of 1997 or
something like that
[measures].[cumulative sales] on rows

from.....


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote

Quote:
Hmm..

YTD isnt quite what I am after...

Here is an example of what I have currently..

Using the Foodmart 2000 cube (SALES)

WITH MEMBER Measures.[Cumulative Sales] AS 'SUM( HEAD( ORDER(
{[Time].Siblings}, [Measures].[Unit Sales], BDESC ) AS OrderedSiblings,
RANK( [Time], OrderedSiblings ) ), [Measures].[Unit Sales] )'

SELECT

ORDER( DESCENDANTS( [Time].&[1997] ), [Measures].[Unit Sales], BDESC ) ON
COLUMNS,

{[Measures].[Unit Sales], [Measures].[Cumulative Sales]} ON ROWS

FROM [Sales]



Basically what I want to see on Columns... are the months of 1997... and
each month is cumulative..

The above code kind of works, but doesnt focus purely on month. I need
some help on that.



Thanks!!

"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:u7o8XnW%23FHA.2320 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Check for the ytd() function. It would be something like

sum(ytd([Time].[Calendar]), [Measures].[Sales])

Offcourse, to get results you would have to include time dimension in the
query.


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:upjoUEW%23FHA.2664 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint








Reply With Quote
  #5  
Old   
Clint
 
Posts: n/a

Default Re: Cumulative Sum - 12-06-2005 , 03:52 PM



You know what... YTD will indeed work... Now why doesn't any source MDX book
or otherwise detail this as a solution... Why do they go into order, head
and rank... sigh..

Thanks!!! I really appreciate all your help MC.
"MC" <marko_culo#@#yahoo#.#com#> wrote

Quote:
Could you explain why something like doesnt work:

WITH MEMBER
[measures].[cumulative sales]
as
'
sum(ytd([Time].[Calendar]), [Measures].[Sales])
'

select
[Time].[Calendar].[Month].members, --- put here descendants of 1997 or
something like that
[measures].[cumulative sales] on rows

from.....


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:OPPbRfe%23FHA.3064 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hmm..

YTD isnt quite what I am after...

Here is an example of what I have currently..

Using the Foodmart 2000 cube (SALES)

WITH MEMBER Measures.[Cumulative Sales] AS 'SUM( HEAD( ORDER(
{[Time].Siblings}, [Measures].[Unit Sales], BDESC ) AS OrderedSiblings,
RANK( [Time], OrderedSiblings ) ), [Measures].[Unit Sales] )'

SELECT

ORDER( DESCENDANTS( [Time].&[1997] ), [Measures].[Unit Sales], BDESC ) ON
COLUMNS,

{[Measures].[Unit Sales], [Measures].[Cumulative Sales]} ON ROWS

FROM [Sales]



Basically what I want to see on Columns... are the months of 1997... and
each month is cumulative..

The above code kind of works, but doesnt focus purely on month. I need
some help on that.



Thanks!!

"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:u7o8XnW%23FHA.2320 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Check for the ytd() function. It would be something like

sum(ytd([Time].[Calendar]), [Measures].[Sales])

Offcourse, to get results you would have to include time dimension in
the query.


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:upjoUEW%23FHA.2664 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint










Reply With Quote
  #6  
Old   
MC
 
Posts: n/a

Default Re: Cumulative Sum - 12-07-2005 , 01:21 AM



Dont know, never read them . Feel free to contact me if you need more
help.

MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote

Quote:
You know what... YTD will indeed work... Now why doesn't any source MDX
book or otherwise detail this as a solution... Why do they go into order,
head and rank... sigh..

Thanks!!! I really appreciate all your help MC.
"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:uZ5F1wj%23FHA.272 (AT) tk2msftngp13 (DOT) phx.gbl...
Could you explain why something like doesnt work:

WITH MEMBER
[measures].[cumulative sales]
as
'
sum(ytd([Time].[Calendar]), [Measures].[Sales])
'

select
[Time].[Calendar].[Month].members, --- put here descendants of 1997 or
something like that
[measures].[cumulative sales] on rows

from.....


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:OPPbRfe%23FHA.3064 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hmm..

YTD isnt quite what I am after...

Here is an example of what I have currently..

Using the Foodmart 2000 cube (SALES)

WITH MEMBER Measures.[Cumulative Sales] AS 'SUM( HEAD( ORDER(
{[Time].Siblings}, [Measures].[Unit Sales], BDESC ) AS OrderedSiblings,
RANK( [Time], OrderedSiblings ) ), [Measures].[Unit Sales] )'

SELECT

ORDER( DESCENDANTS( [Time].&[1997] ), [Measures].[Unit Sales], BDESC )
ON COLUMNS,

{[Measures].[Unit Sales], [Measures].[Cumulative Sales]} ON ROWS

FROM [Sales]



Basically what I want to see on Columns... are the months of 1997... and
each month is cumulative..

The above code kind of works, but doesnt focus purely on month. I need
some help on that.



Thanks!!

"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:u7o8XnW%23FHA.2320 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Check for the ytd() function. It would be something like

sum(ytd([Time].[Calendar]), [Measures].[Sales])

Offcourse, to get results you would have to include time dimension in
the query.


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:upjoUEW%23FHA.2664 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint












Reply With Quote
  #7  
Old   
Clint
 
Posts: n/a

Default Re: Cumulative Sum - 12-07-2005 , 04:07 PM



Thanks for everything...
"MC" <marko_culo#@#yahoo#.#com#> wrote

Quote:
Dont know, never read them . Feel free to contact me if you need more
help.

MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:eKsqe9q%23FHA.2628 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
You know what... YTD will indeed work... Now why doesn't any source MDX
book or otherwise detail this as a solution... Why do they go into
order, head and rank... sigh..

Thanks!!! I really appreciate all your help MC.
"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:uZ5F1wj%23FHA.272 (AT) tk2msftngp13 (DOT) phx.gbl...
Could you explain why something like doesnt work:

WITH MEMBER
[measures].[cumulative sales]
as
'
sum(ytd([Time].[Calendar]), [Measures].[Sales])
'

select
[Time].[Calendar].[Month].members, --- put here descendants of 1997
or something like that
[measures].[cumulative sales] on rows

from.....


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:OPPbRfe%23FHA.3064 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hmm..

YTD isnt quite what I am after...

Here is an example of what I have currently..

Using the Foodmart 2000 cube (SALES)

WITH MEMBER Measures.[Cumulative Sales] AS 'SUM( HEAD( ORDER(
{[Time].Siblings}, [Measures].[Unit Sales], BDESC ) AS OrderedSiblings,
RANK( [Time], OrderedSiblings ) ), [Measures].[Unit Sales] )'

SELECT

ORDER( DESCENDANTS( [Time].&[1997] ), [Measures].[Unit Sales], BDESC )
ON COLUMNS,

{[Measures].[Unit Sales], [Measures].[Cumulative Sales]} ON ROWS

FROM [Sales]



Basically what I want to see on Columns... are the months of 1997...
and each month is cumulative..

The above code kind of works, but doesnt focus purely on month. I need
some help on that.



Thanks!!

"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:u7o8XnW%23FHA.2320 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Check for the ytd() function. It would be something like

sum(ytd([Time].[Calendar]), [Measures].[Sales])

Offcourse, to get results you would have to include time dimension in
the query.


MC

"Clint" <ccpatriot12 (AT) yahoo (DOT) com> wrote in message
news:upjoUEW%23FHA.2664 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Hello All,

I am trying to get a measure that will sum the sales for this year.

For example
January Sales =10000
February Sales=20000

Thus in AS I want to see the Cumulative Sales for February=30000

What is the best way to do this?

Thanks

Clint














Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.