dbTalk Databases Forums  

Running Total in 1 Level? How?

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


Discuss Running Total in 1 Level? How? in the microsoft.public.sqlserver.olap forum.



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

Default Running Total in 1 Level? How? - 12-03-2003 , 08:57 AM






I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any help
is greatly appreciated. Also, I am running the Standard
version of SQL 2000.

Trevor


Reply With Quote
  #2  
Old   
Mike Morse
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 09:30 AM






Trevor,
Can you try creating a calculated measures that is like so:

([StatementCode].Parent, [Measures].[Total]) + ([Measures].
[Total])

You may want to hide your original Measures.Total so it no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other levels
will work as you need.

-mike


Quote:
-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any help
is greatly appreciated. Also, I am running the Standard
version of SQL 2000.

Trevor

.


Reply With Quote
  #3  
Old   
Trevor B
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 10:00 AM




I tried your suggestion but it does not produce the
required results.

This would be acceptable.


Quote:
USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48


-----Original Message-----
Trevor,
Can you try creating a calculated measures that is like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the Standard
version of SQL 2000.

Trevor

.

.


Reply With Quote
  #4  
Old   
Trevor B
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 10:18 AM



Actually, this does produce a running total, but I think I
need an IIf statement to confine the running total to just
the second level of the Dimension.


Quote:
-----Original Message-----
Trevor,
Can you try creating a calculated measures that is like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the Standard
version of SQL 2000.

Trevor

.

.


Reply With Quote
  #5  
Old   
mike morse
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 10:53 AM



So, only on the second level you want to keep a running
total and other levels to be normal.

This should take care of that if I understand your goal
correctly.

IIF([Account].CurrentMember.Level.Name = "Level 02" ,
([StatementCode].Parent, [Measures].[Total]) + ([Measures].
[Total]), [Measures].[Total])


-mike

Quote:
-----Original Message-----

I tried your suggestion but it does not produce the
required results.

This would be acceptable.


USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48


-----Original Message-----
Trevor,
Can you try creating a calculated measures that is like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other
levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the Standard
version of SQL 2000.

Trevor

.

.

.


Reply With Quote
  #6  
Old   
Trevor B
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 11:28 AM



Mike, we are getting very close, but it seems the first
value in the running total should equal the first value in
the level, but it does not. It seems to be adding some
other values from the parent into the running total.

I made a change and used currentMember but still get
messed up values.

IIF( [StatementCode].CurrentMember.Level.Name
= "S2s2desc", ([StatementCode].CurrentMember, [Measures].
[USDBal]) + ([Measures]. [USDBal]), Null )

Quote:
USDBal Running Total
5 - 14,665,974.97 29,332,568.46
10 - (5,554,260.80) -11,108,521.88
15 - 1,372,785.75 2,745,571.46
20 - (8,159,472.30) -16,318,942.50
30 - 21,330.24 42,660.48
35 - (1,078,496.38) -2,156,992.76
40 - (434,210.00) -833,651.48
Should be:

Quote:
USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48

-----Original Message-----
So, only on the second level you want to keep a running
total and other levels to be normal.

This should take care of that if I understand your goal
correctly.

IIF([Account].CurrentMember.Level.Name = "Level 02" ,
([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total]), [Measures].[Total])


-mike

-----Original Message-----

I tried your suggestion but it does not produce the
required results.

This would be acceptable.


USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48


-----Original Message-----
Trevor,
Can you try creating a calculated measures that is like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other
levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the
Standard
version of SQL 2000.

Trevor

.

.

.

.


Reply With Quote
  #7  
Old   
Brian Altmann
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 11:42 AM



You can try the recursive way:

[statement code].prevmember + ([statement].currentmember,
[base measure])

or the non-recursive way:

sum(head([statement
code].currentmember.level.members,1).item(0):[statement
code].currentmember,[base measure])

HTH,
Brian
www.geocities.com/brianaltmann/olap.html



Quote:
-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any help
is greatly appreciated. Also, I am running the Standard
version of SQL 2000.

Trevor

.


Reply With Quote
  #8  
Old   
Trevor B
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 11:52 AM



This is essentially what is happening, which is not a
running total.

Quote:
USDBal Running Total
5 - 14,665,974.97 * 2 = 29,332,568.46
10 - (5,554,260.80) * 2 = -11,108,521.88
15 - 1,372,785.75 etc.. 2,745,571.46
20 - (8,159,472.30) -16,318,942.50
30 - 21,330.24 42,660.48
35 - (1,078,496.38) -2,156,992.76
40 - (434,210.00) -833,651.48
-----Original Message-----
So, only on the second level you want to keep a running
total and other levels to be normal.

This should take care of that if I understand your goal
correctly.

IIF([Account].CurrentMember.Level.Name = "Level 02" ,
([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total]), [Measures].[Total])


-mike

-----Original Message-----

I tried your suggestion but it does not produce the
required results.

This would be acceptable.


USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48


-----Original Message-----
Trevor,
Can you try creating a calculated measures that is like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other
levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the
Standard
version of SQL 2000.

Trevor

.

.

.

.


Reply With Quote
  #9  
Old   
mike morse
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 11:55 AM



Maybe it would help if we talk psuedo code for a minute.

The MDX you wrote says this:
IIF(WereAtLevel2, ThenDisplayMyUSDBalAddedToMyUSDBal,
OtherWiseDisplayNull)

You could even simplify the MDX you wrote to this:
IIF([StatementCode].CurrentMember.Level.Name = "S2s2desc",
[Measures].[USDBal] + [Measures].[USDBal], Null)

CurrentMember is just assumed by AS therefore you really
don't need to call it out.

This is what I thought you are trying to do:
Iff(WereAtLevel2,
ThenDisplayMyUSDBalAddedToMyParentsUSDBal,
OtherWiseDisplayMyUSDBal)

Let me know...

-mike


Quote:
-----Original Message-----
Mike, we are getting very close, but it seems the first
value in the running total should equal the first value
in
the level, but it does not. It seems to be adding some
other values from the parent into the running total.

I made a change and used currentMember but still get
messed up values.

IIF( [StatementCode].CurrentMember.Level.Name
= "S2s2desc", ([StatementCode].CurrentMember, [Measures].
[USDBal]) + ([Measures]. [USDBal]), Null )

USDBal Running Total
5 - 14,665,974.97 29,332,568.46
10 - (5,554,260.80) -11,108,521.88
15 - 1,372,785.75 2,745,571.46
20 - (8,159,472.30) -16,318,942.50
30 - 21,330.24 42,660.48
35 - (1,078,496.38) -2,156,992.76
40 - (434,210.00) -833,651.48

Should be:

USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48

-----Original Message-----
So, only on the second level you want to keep a running
total and other levels to be normal.

This should take care of that if I understand your goal
correctly.

IIF([Account].CurrentMember.Level.Name = "Level 02" ,
([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total]), [Measures].[Total])


-mike

-----Original Message-----

I tried your suggestion but it does not produce the
required results.

This would be acceptable.


USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48


-----Original Message-----
Trevor,
Can you try creating a calculated measures that is
like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so
it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other
levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the
Standard
version of SQL 2000.

Trevor

.

.

.

.

.


Reply With Quote
  #10  
Old   
Trevor B
 
Posts: n/a

Default Running Total in 1 Level? How? - 12-03-2003 , 12:09 PM



OK, I got it to work by doing the following:

IIF( [StatementCode].CurrentMember.Level.Name
= "S2s2desc", ([StatementCode].CurrentMember.PrevMember,
[Measures].[Usdbal]) + ([Measures]. [Usdbal]), Null )

Quote:
-----Original Message-----
Maybe it would help if we talk psuedo code for a minute.

The MDX you wrote says this:
IIF(WereAtLevel2, ThenDisplayMyUSDBalAddedToMyUSDBal,
OtherWiseDisplayNull)

You could even simplify the MDX you wrote to this:
IIF([StatementCode].CurrentMember.Level.Name = "S2s2desc",
[Measures].[USDBal] + [Measures].[USDBal], Null)

CurrentMember is just assumed by AS therefore you really
don't need to call it out.

This is what I thought you are trying to do:
Iff(WereAtLevel2,
ThenDisplayMyUSDBalAddedToMyParentsUSDBal,
OtherWiseDisplayMyUSDBal)

Let me know...

-mike


-----Original Message-----
Mike, we are getting very close, but it seems the first
value in the running total should equal the first value
in
the level, but it does not. It seems to be adding some
other values from the parent into the running total.

I made a change and used currentMember but still get
messed up values.

IIF( [StatementCode].CurrentMember.Level.Name
= "S2s2desc", ([StatementCode].CurrentMember, [Measures].
[USDBal]) + ([Measures]. [USDBal]), Null )

USDBal Running Total
5 - 14,665,974.97 29,332,568.46
10 - (5,554,260.80) -11,108,521.88
15 - 1,372,785.75 2,745,571.46
20 - (8,159,472.30) -16,318,942.50
30 - 21,330.24 42,660.48
35 - (1,078,496.38) -2,156,992.76
40 - (434,210.00) -833,651.48

Should be:

USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48

-----Original Message-----
So, only on the second level you want to keep a running
total and other levels to be normal.

This should take care of that if I understand your goal
correctly.

IIF([Account].CurrentMember.Level.Name = "Level 02" ,
([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total]), [Measures].[Total])


-mike

-----Original Message-----

I tried your suggestion but it does not produce the
required results.

This would be acceptable.


USDBal Running Total
5 - 14,665,974.97 14,665,974.97
10 - (5,554,260.80) 9,111,714.17
15 - 1,372,785.75 10,484,499.92
20 - (8,159,472.30) 2,325,027.62
30 - 21,330.24 2,346,357.86
35 - (1,078,496.38) 1,267,861.48
40 - (434,210.00) 833,651.48


-----Original Message-----
Trevor,
Can you try creating a calculated measures that is
like
so:

([StatementCode].Parent, [Measures].[Total]) +
([Measures].
[Total])

You may want to hide your original Measures.Total so
it
no
longer shows up.

At the top most level it will display simply the
measures.total since there is no parent. All other
levels
will work as you need.

-mike


-----Original Message-----
I have a Dimension called StatementCode which has 5
Levels. I would like to calculate a running total
for
the
members of the second level (s2code).
So instead of showing this (i hope the formatting is
preserved):

5 - 14,665,974.97
10 - (5,554,260.80)
15 - 1,372,785.75
20 - (8,159,472.30)
30 - 21,330.24
35 - (1,078,496.38)
40 - (434,210.00)

I would like to show this:

5 - 14,665,974.97
10 - 9,111,714.17
15 - 10,484,499.92
20 - 2,325,027.62
30 - 2,346,357.86
35 - 1,267,861.48
40 - 833,651.48

Please let me know if you need more information, any
help
is greatly appreciated. Also, I am running the
Standard
version of SQL 2000.

Trevor

.

.

.

.

.

.


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.