Showing posts with label wrong. Show all posts
Showing posts with label wrong. Show all posts

Friday, February 10, 2012

Calculated member wrong behaviour in Reporting Services

Hello,

I've created a SQL Server2005 AS Cube with a YTD calculated member:

Sum (YTD(),[Measures].[measure X])

This member (and others give the right results in the cube browser as well in an Excel pivot table). In a parameterized (year-month) report in Reporting services this does not work. It gives only the data of the given moth instead of the sum of all the months in the given year.

Can somebody help me with this issue?

Thanks!

Pieter

Hi Pieter,

What is the MDX query used in the report and what does your time dimension look like - I'm assuming that this problem occurs even with a fixed (no parameters) query?

|||

Thanx for your reply,

the YTD measures work correctly now both in the AS browser as in Reporting services, I redesigned the time dimension in AS. The only member whis does'nt work correctly in RS is a year total. this total works correct in the AS browser and also in RS without a parameter on time (month). It has to return the yeartotal regardless on what time is given in the parameter

The member looks as follows:

Measure Y:

sum(ancestors([Time dimension].[Hierarchy Year-Halfyear-Quarter-Month-Day].currentmember,[Time dimension].[Hierarchy Year-Halfyear-Quarter-Month-Day].[Year]),[Measures].[Measure X])

This is the MDX quert which is generated by RS:

SELECT NON EMPTY { [Measures].[Measure Y], [Measures].[Measure X] } ON COLUMNS FROM ( SELECT ( STRTOSET(@.Timedimensionhierarchyyearmonth, CONSTRAINED) ) ON COLUMNS FROM [ Cube]) WHERE ( IIF( STRTOSET(@.Timedimensionhierarchyyearmonth, CONSTRAINED).Count = 1, STRTOSET(@.Timedimensionhierarchyyearmonth, CONSTRAINED), [Time dimension].[Hierarchy year-month].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Calculated Member not working

Please could somebody help me to understand what is wrong with the following calculated member definition (tried many variations of this now, always the same problem)

CREATE MEMBER CURRENTCUBE.[MEASURES].RatioVal

AS [Measures].[Val] / SUM(([Tbl Acc Codes].[Tbl Acc Lvl1].&[OUR],[Tbl Acc Codes].[Tbl Acc Lvl2].&[CORE],[Tbl Acc Codes].[Tbl Acc Lvl3 - Lvl 3 Code].&[INCOME]),[Measures].[Val]),

NON_EMPTY_BEHAVIOR = { [Val] },

VISIBLE = 1 ;

All I want is to show in cube browser alongside Measures.Val is another member called RatioVal.

RatioVal should be Val divided by the sum of Val with a lvl1 of 'OUR', a lvl2 of 'CORE' and a lvl3 of 'INCOME'

At the moment when I browse my cube I get a RatioVal subtotal for each lvl1, and each lvl2 but anything deeper into the hierarchy than that shows 1.#INF

Please give me any clues you can, this is driving me nuts!

Thanks

Hi Wayne,

The 1.#NF error indicates division by zero - so I would guess that your problem is caused by the expression

SUM(([Tbl Acc Codes].[Tbl Acc Lvl1].&[OUR],[Tbl Acc Codes].[Tbl Acc Lvl2].&[CORE],[Tbl Acc Codes].[Tbl Acc Lvl3 - Lvl 3 Code].&[INCOME]),[Measures].[Val]),

evaluating to zero at the lower levels. Without knowing more about your cube I can't say why this might be though.

Even after you've fixed this, if you think that there's ever chance that this expression could still evaluate to zero, then you should put add a test to your calculated member to handle this scenario, something like this:

CREATE MEMBER CURRENTCUBE.[MEASURES].RatioVal

AS

IIF(SUM(([Tbl Acc Codes].[Tbl Acc Lvl1].&[OUR],[Tbl Acc Codes].[Tbl Acc Lvl2].&[CORE],[Tbl Acc Codes].[Tbl Acc Lvl3 - Lvl 3 Code].&[INCOME]),[Measures].[Val]) = 0, NULL,

[Measures].[Val] / SUM(([Tbl Acc Codes].[Tbl Acc Lvl1].&[OUR],[Tbl Acc Codes].[Tbl Acc Lvl2].&[CORE],[Tbl Acc Codes].[Tbl Acc Lvl3 - Lvl 3 Code].&[INCOME]),[Measures].[Val])

),

NON_EMPTY_BEHAVIOR = { [Val] },

VISIBLE = 1 ;

HTH,

Chris