SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Cube Claculations


Cube Claculations

Author
Message
Ells
Ells
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2402 Visits: 931
SSAS 2012
Bit of a weird issue here. Created some cube calculations.


CREATE MEMBER CURRENTCUBE.[Measures].[SLl]
AS
CASE WHEN [Measures].[R]= 0 THEN 0
ELSE ([Measures].[I]/[Measures].[R] )
END,
FORMAT_STRING = "00.00%",
VISIBLE = 01 , ASSOCIATED_MEASURE_GROUP = 'LS' ;



for some reason when I have the dimension Product on rows then the Measures I and R may be null (no fact records) , but there is a row for the Product dimension member.

I have tried this In cube browser and Excel 2007. I feel like I am missing something here. When I have done this previously (too many years working in SSIS and not enough SSAS) this work perfectly.

What am I missing.
Cheers
E
Ells
Ells
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2402 Visits: 931
Should say I know this can be filtered out when querying but I want it to be right in the cube in the first place.

Thanks
E
PB_BI
PB_BI
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4221 Visits: 2732
A few things could be causing this....

Firstly your code:
CASE WHEN [Measures].[R]= 0 THEN 0


This returns a zero rather than a NULL so any NON EMPTY precedents in the queries (these are there by default in the cube browser and Excel) will not work as expected. This may be causing your issue.

Secondly the form of your code is not considered the best in terms of performance. Try:
IIF( [Measures].[R]=0, NULL, [Measures].[I]/[Measures].[R] )



The reasons for this are discussed here: http://sqlblog.com/blogs/mosha/archive/2007/01/28/performance-of-iif-function-in-mdx.aspx




I'm on LinkedIn
Ells
Ells
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2402 Visits: 931
Many thanks,
I have been playing with this for a little this morning and have changed it so that if [Measures].[R] = 0 THEN [Measures].[R]

Not happy with that but it does the trick for removing the rows that should be NULLS. Just having a look at the IIF statement link.

Thanks
E
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search