dbTalk Databases Forums  

Cube creation

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


Discuss Cube creation in the microsoft.public.sqlserver.olap forum.



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

Default Cube creation - 04-14-2004 , 09:22 PM






Hello,

I have one table that has the following columns:
AccountNum, AccountName, Date, Amount

I require a cube to have two measures: Debit and Credit...

Credit = Amount when <0
Debit = Amount when >0

So the cube will look something like this:

Dimension: [Date.Year].June

AccountNum AccountName Debit Credit
100 Revenue -500 400

Can anyone assist as I am stumped.

Thanks

Clint



Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Cube creation - 04-14-2004 , 11:41 PM






Create 3 dimensions: AccountNum, AccountName, and Date joining to those
3 columns. Then define 2 measures (having Sum aggregation function) with
these Source Columns:

Credit>> case when Fact.Amount > 0
then Fact.Amount else 0 end

Debit>> case when Fact.Amount < 0
then Fact.Amount else 0 end


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: Cube creation - 04-15-2004 , 01:31 AM



Thanks for your assistance, I have followed your instructions however, both
positive and negative values are being added to both Credit and Debit. Any
further ideas?
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
Create 3 dimensions: AccountNum, AccountName, and Date joining to those
3 columns. Then define 2 measures (having Sum aggregation function) with
these Source Columns:

Credit>> case when Fact.Amount > 0
then Fact.Amount else 0 end

Debit>> case when Fact.Amount < 0
then Fact.Amount else 0 end


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply With Quote
  #4  
Old   
Andrej Hudoklin
 
Posts: n/a

Default Re: Cube creation - 04-15-2004 , 02:14 AM



You have to create a fact table that has 2 columns!

create a fact table with 2 select statements like:

select AccountNum, AccountName, Date, Amount as Debit, null as Credit
from table
where amount > 0

union all

select AccountNum, AccountName, Date, null as Debit, Amount as Credit
from table
where amount < 0


and this is your fact table, and you have 2 basic measures!

Simple as that!

hope it helps!

Peace,
Andrej



"AshVsAOD" <.> wrote

Quote:
Thanks for your assistance, I have followed your instructions however,
both
positive and negative values are being added to both Credit and Debit.
Any
further ideas?
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote in message
news:e2Ii1PqIEHA.3432 (AT) tk2msftngp13 (DOT) phx.gbl...
Create 3 dimensions: AccountNum, AccountName, and Date joining to those
3 columns. Then define 2 measures (having Sum aggregation function) with
these Source Columns:

Credit>> case when Fact.Amount > 0
then Fact.Amount else 0 end

Debit>> case when Fact.Amount < 0
then Fact.Amount else 0 end


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





Reply With Quote
  #5  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Cube creation - 04-15-2004 , 01:53 PM



From what you are describing, you may not have defined the "Source
Column" SQL expressions as explained below.

For example, if "Source Column" expression for Credit is:
Quote:
case when Fact.Amount > 0 then Fact.Amount else 0 end

then ONLY positive amounts will be summed under Credit.

And if the "Source Column" expression for Debit is:
Quote:
case when Fact.Amount < 0 then Fact.Amount else 0 end

then ONLY negative amounts will be summed under Debit.

Of course, I'm assuming that you are using a relational data source
(such as SQL Server) which implements case.


You can follow the other suggestion, and create a new fact table/view
with 2 columns for Debit/Credit, if you prefer.


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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

Default Re: Cube creation - 04-15-2004 , 05:45 PM



Thanks very much for all your assistance. My knowledge of OLAP and
everything surrounding the tech is growing but still very light on. I
recreated the cube a second time using your described method with success.
I must have mispelt something or other. I really do appreciate your help.

Kind Regards

Clint
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
From what you are describing, you may not have defined the "Source
Column" SQL expressions as explained below.

For example, if "Source Column" expression for Credit is:

case when Fact.Amount > 0 then Fact.Amount else 0 end

then ONLY positive amounts will be summed under Credit.

And if the "Source Column" expression for Debit is:

case when Fact.Amount < 0 then Fact.Amount else 0 end

then ONLY negative amounts will be summed under Debit.

Of course, I'm assuming that you are using a relational data source
(such as SQL Server) which implements case.


You can follow the other suggestion, and create a new fact table/view
with 2 columns for Debit/Credit, if you prefer.


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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

Default Re: Cube creation - 04-15-2004 , 05:47 PM



That would work too... D'oh... sometimes the simplist methods are the
best... Thanks... I am already using UNION ALL elsewhere don't know why I
didn't think of unioning the same table.

Thanks!
"Andrej Hudoklin" <andrej.hudoklin (AT) add (DOT) si> wrote

Quote:
You have to create a fact table that has 2 columns!

create a fact table with 2 select statements like:

select AccountNum, AccountName, Date, Amount as Debit, null as Credit
from table
where amount > 0

union all

select AccountNum, AccountName, Date, null as Debit, Amount as Credit
from table
where amount < 0


and this is your fact table, and you have 2 basic measures!

Simple as that!

hope it helps!

Peace,
Andrej



"AshVsAOD" <.> wrote in message
news:%23WWXaNrIEHA.2480 (AT) tk2msftngp13 (DOT) phx.gbl...
Thanks for your assistance, I have followed your instructions however,
both
positive and negative values are being added to both Credit and Debit.
Any
further ideas?
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote in message
news:e2Ii1PqIEHA.3432 (AT) tk2msftngp13 (DOT) phx.gbl...
Create 3 dimensions: AccountNum, AccountName, and Date joining to
those
3 columns. Then define 2 measures (having Sum aggregation function)
with
these Source Columns:

Credit>> case when Fact.Amount > 0
then Fact.Amount else 0 end

Debit>> case when Fact.Amount < 0
then Fact.Amount else 0 end


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!







Reply With Quote
  #8  
Old   
AshVsAOD
 
Posts: n/a

Default Re: Cube creation - 04-16-2004 , 01:03 AM



I have discovered what I did wrong <whew>..

It appears that although the amounts in both debit and credit work fine,
using Drill to detail shows all records irrespective of whether or not it is
a credit or debit.

I will need to investigate this when I can source some time.
"AshVsAOD" <.> wrote

Quote:
Thanks very much for all your assistance. My knowledge of OLAP and
everything surrounding the tech is growing but still very light on. I
recreated the cube a second time using your described method with success.
I must have mispelt something or other. I really do appreciate your
help.

Kind Regards

Clint
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote in message
news:etL4irxIEHA.2236 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
From what you are describing, you may not have defined the "Source
Column" SQL expressions as explained below.

For example, if "Source Column" expression for Credit is:

case when Fact.Amount > 0 then Fact.Amount else 0 end

then ONLY positive amounts will be summed under Credit.

And if the "Source Column" expression for Debit is:

case when Fact.Amount < 0 then Fact.Amount else 0 end

then ONLY negative amounts will be summed under Debit.

Of course, I'm assuming that you are using a relational data source
(such as SQL Server) which implements case.


You can follow the other suggestion, and create a new fact table/view
with 2 columns for Debit/Credit, if you prefer.


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





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.