dbTalk Databases Forums  

Calculate Hit Rate?

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


Discuss Calculate Hit Rate? in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
garrett.fitzsimons@gmail.com
 
Posts: n/a

Default Calculate Hit Rate? - 11-22-2006 , 04:37 PM






Hi,

I want to calculate the amount of 'fact' rows with a certain value as a
percentage of the total number of fact rows.

For example, a test cube has 5000 rows. 2500 of these rows have a
sale-status of 'Complete' or 'Closed' - designated by a surrogate key
in the fact-table.

So, my hit-rate should be 50%. In the example below I have hard-coded
the value of '2500'. What logic can I insert here to produce the
calculation ?

Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count] -2500 ) /
[Measures].[Sales Count])
End

Many Thanks,
Gar.


Reply With Quote
  #2  
Old   
Jéjé
 
Posts: n/a

Default Re: Calculate Hit Rate? - 11-22-2006 , 06:02 PM






if you have a dimension like "status"
try:
Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count], Status.[Closed] ) /
[Measures].[Sales Count])
End


([Measures].[Sales Count], Status.[Closed] ) return the sales count value
but for closed only.

if you don't have a dimension "status" and don't want one...
add a new measure in the cube linked to this SQL statement:
case when StatusColumn='Closed' then 1 else 0 end
map this new calculated column to a measure like "Closed Sales" (a using a
sum aggregation or a count aggr.)
and the formula become:
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else [Measures].[Closed Sales]/
[Measures].[Sales Count]
End


does this helps you?



<garrett.fitzsimons (AT) gmail (DOT) com> wrote

Quote:
Hi,

I want to calculate the amount of 'fact' rows with a certain value as a
percentage of the total number of fact rows.

For example, a test cube has 5000 rows. 2500 of these rows have a
sale-status of 'Complete' or 'Closed' - designated by a surrogate key
in the fact-table.

So, my hit-rate should be 50%. In the example below I have hard-coded
the value of '2500'. What logic can I insert here to produce the
calculation ?

Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count] -2500 ) /
[Measures].[Sales Count])
End

Many Thanks,
Gar.


Reply With Quote
  #3  
Old   
garrett.fitzsimons@gmail.com
 
Posts: n/a

Default Re: Calculate Hit Rate? - 11-24-2006 , 08:05 AM




Jéjé,

Many Thanks - I do have a Status Dim. and all is well.

As a follow-up if wanted to expand this scenario and change the
hard-coded [Closed] to reference a set of 'Status' in the same way as
you would a sub-select how would this be achieved ?

Rgds,
Garrett.


Jéjé wrote:
Quote:
if you have a dimension like "status"
try:
Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count], Status.[Closed] ) /
[Measures].[Sales Count])
End


([Measures].[Sales Count], Status.[Closed] ) return the sales count value
but for closed only.

if you don't have a dimension "status" and don't want one...
add a new measure in the cube linked to this SQL statement:
case when StatusColumn='Closed' then 1 else 0 end
map this new calculated column to a measure like "Closed Sales" (a using a
sum aggregation or a count aggr.)
and the formula become:
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else [Measures].[Closed Sales]/
[Measures].[Sales Count]
End


does this helps you?



garrett.fitzsimons (AT) gmail (DOT) com> wrote in message
news:1164235025.577157.324410 (AT) m7g2000cwm (DOT) googlegroups.com...
Hi,

I want to calculate the amount of 'fact' rows with a certain value as a
percentage of the total number of fact rows.

For example, a test cube has 5000 rows. 2500 of these rows have a
sale-status of 'Complete' or 'Closed' - designated by a surrogate key
in the fact-table.

So, my hit-rate should be 50%. In the example below I have hard-coded
the value of '2500'. What logic can I insert here to produce the
calculation ?

Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count] -2500 ) /
[Measures].[Sales Count])
End

Many Thanks,
Gar.



Reply With Quote
  #4  
Old   
Jéjé
 
Posts: n/a

Default Re: Calculate Hit Rate? - 11-24-2006 , 09:59 AM



if you want a "% of total" calculation (I mean % in the selected status):
Quote:
Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else [Measures].[Sales Count] /
([Measures].[Sales Count], Status.[All status])
End
or
Quote:
Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else [Measures].[Sales Count] /
(root(status), [Measures].[Sales Count])
End
this evaluate the % of sales count in the selected status


<garrett.fitzsimons (AT) gmail (DOT) com> wrote


Jéjé,

Many Thanks - I do have a Status Dim. and all is well.

As a follow-up if wanted to expand this scenario and change the
hard-coded [Closed] to reference a set of 'Status' in the same way as
you would a sub-select how would this be achieved ?

Rgds,
Garrett.


Jéjé wrote:
Quote:
if you have a dimension like "status"
try:
Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count], Status.[Closed] ) /
[Measures].[Sales Count])
End


([Measures].[Sales Count], Status.[Closed] ) return the sales count
value
but for closed only.

if you don't have a dimension "status" and don't want one...
add a new measure in the cube linked to this SQL statement:
case when StatusColumn='Closed' then 1 else 0 end
map this new calculated column to a measure like "Closed Sales" (a using a
sum aggregation or a count aggr.)
and the formula become:
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else [Measures].[Closed Sales]/
[Measures].[Sales Count]
End


does this helps you?



garrett.fitzsimons (AT) gmail (DOT) com> wrote in message
news:1164235025.577157.324410 (AT) m7g2000cwm (DOT) googlegroups.com...
Hi,

I want to calculate the amount of 'fact' rows with a certain value as a
percentage of the total number of fact rows.

For example, a test cube has 5000 rows. 2500 of these rows have a
sale-status of 'Complete' or 'Closed' - designated by a surrogate key
in the fact-table.

So, my hit-rate should be 50%. In the example below I have hard-coded
the value of '2500'. What logic can I insert here to produce the
calculation ?

Case
When IsEmpty( [Measures].[Sales Count] )
Then 0
Else ( ([Measures].[Sales Count] -2500 ) /
[Measures].[Sales Count])
End

Many Thanks,
Gar.


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.