Showing posts with label measures. Show all posts
Showing posts with label measures. Show all posts

Saturday, February 25, 2012

Annualizing Measures

In the financial services world, a common requirement is to annualized a value. We've made several attempts at this. The challenge comes when using a standard Date hierarchy (Year, Quarter, Month, Date). We need to annualized a measure based on a running total of the last 6 months. We also need to take into account the early dates of the warehouse where X Months might not be available by multiplying the aggregate it by Y divided by the count of non-empty members.

This seems to work for this part of the problem:

Create Member CurrentCube.[Measures].[Rolling 6m Contribution]
AS Case
When COUNT(LASTPERIODS(6, [Date].[Month].CurrentMember), EXCLUDEEMPTY) + 1 < 6
Then Aggregate(LASTPERIODS ( 6, [Date].[Month].CurrentMember),[Measures].[Total Contribution])
* 6 /
(COUNT(LASTPERIODS(6, [Date].[Month].CurrentMember), EXCLUDEEMPTY) + 1)
Else
Aggregate(LASTPERIODS ( 6, [Date].[Month].CurrentMember),[Measures].[Total Contribution])
End,
Format_String = "Currency",
Non_Empty_Behavior = [Measures].[Total Contribution],
Visible = 1;

We've also tried this with the YTD function, but using YTD give a small sample size for the annual figure in the first months of each year.

Next, we need to be able to make the rolling sum work at all levels of the date hierarchy. This basically needs to act like LastNonEmpty aggregation on normal measures. We created a second measure:

Create Member CurrentCube.[Measures].[Rolling 6a Contribution]
AS
([Measures].[Rolling 6m Contribution],
ClosingPeriod([Date].[Calendar Year Hierarchy].[Month],
[Date].[Calendar Year Hierarchy].CurrentMember)),
Format_String = "Currency",
Non_Empty_Behavior = [Measures].[Total Contribution],
Visible = 1;

This seems to work for Year and Quarter except that the final Year has a Null value.

Does anyone have any suggestions on annualization in general or what we're doing wrong in the code above?

Im am not sure that I can solve all your business/MDX problems but it seems to me that you will need a sliding time member.

Here is a thread that I have participated in that perhaps can give you a clue: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=996037&SiteID=1

Mosha have also a good post on his BLOG(http://www.sqljunkies.com/WebLog/mosha/archive/2006/10/25/time_calculations_parallelperiod.aspx)

HTH

Thomas Ivarsson

|||

Thanks for the suggestion Thomas. Both posts as well as Danial Shroyer white paper have great info.

However, my problem here isn't so much getting the running total as making it work with a user hierarchy. In the first code sample above, I can get the the sliding total. I can't figure out how to have the year and quarter levels reflect the monthly amount like a LastNonEmpty measure. For example, in November or 2006, the 2006 level needs to be November's sliding total (times 2 to annualize). The second code sample almost works.

|||

To clarify a bit, what I need is a running total that can be shown along side other measures and calculated measures in a report. The follwing MDX:

Create Member CurrentCube.[Measures].[Rolling 6m Contribution]
AS Case
When COUNT(LASTPERIODS(6, [Date].[Month].CurrentMember), EXCLUDEEMPTY) + 1 < 6
Then Aggregate(LASTPERIODS ( 6, [Date].[Month].CurrentMember),[Measures].[Total Contribution])
* 6 /
(COUNT(LASTPERIODS(6, [Date].[Month].CurrentMember), EXCLUDEEMPTY) + 1)
Else
Aggregate(LASTPERIODS ( 6, [Date].[Month].CurrentMember),[Measures].[Total Contribution])
End,
Format_String = "Currency",
Non_Empty_Behavior = [Measures].[Total Contribution],
Visible = 1;

Yields the following results in OWC:

Total

Rolling 6 Month

Contribution

Contribution

2005

2005Q4

October

$14,976.53

$89,859.15

November

$14,671.37

$88,943.69

December

($21,538.80)

$16,218.19

Total

$8,109.09

$16,218.19

Total

$8,109.09

$16,218.19

2006

2006Q1

January

($6,454.19)

$2,482.35

February

($7,457.21)

($6,962.77)

March

($24,603.15)

($30,405.45)

Total

($38,514.55)

($30,405.45)

2006Q2

April

$331,735.57

$286,353.60

May

$330,722.83

$602,405.06

June

$406,411.19

$1,030,355.05

Total

$1,068,869.60

$1,030,355.05

2006Q3

July

$334,866.69

$1,371,675.93

August

$391,630.62

$1,770,763.76

September

$410,589.62

$2,205,956.53

Total

$1,137,086.93

$2,205,956.53

Total

$2,167,441.98

The adustment for the first 5 months of data in the warehouse works and the running sum works for 2005, all quarters, and all months. The remaining problem is the missing total for 2006. Can anyone tell my why this doesn't work?

|||

For anyone who's interested, the problem in the above example is that 2006 hasn't "closed" yet. ClosingPeriod returns the last child of Year, but since there's no fact data in the cube for December yet, the result is null.

It would be great if you could set aggregation on a calculated member (LastNonEmpty).

Sunday, February 12, 2012

Analysis Services Cube Measures showing #ERR

Hi,

We have a MS OLAP Cube using 10 dimensions and 1 fact table with measures as COUNT and DISTINCT COUNT.

When we processed the cube using Analysis Services, it was done but all the measures are showing #ERR as values. The cube is about 650MB in size and all the joins between Dimension and Fact tables seem to be OK.

What could be the possible reasons of getting #ERR in measures? Do all the datatypes and length of JOIN columns between dimension and fact HAVE TO BE the same??

Please provide any inputs as this is very urgent.
Thanks
Omkarid assume its some division by 0 error

you can deal with this by replacing a Zero with a NULL in whatever field you use as a denominator. (the bottom half of division-- i hope that was the right word)

Analysis Services Calculations

Is it possible to group/ arrange Analysis Services Calculations in cubes into separate Folders? In other words similart to measures which can be grouped in to folders I would want to know if we can group these calculated meassures into folders.

Thanks

In the calculations tab you can see a very small properties button, called calculation properties, that you can click on.

This is in BI-Dev Studio.

HTH

Thomas Ivarsson

|||

Great, thanks..

Now how can I control the security of these calculated members. meaning, I do not want the calculated field to be available to a pariculat role?

I can control it at the Measure level that makes this calculated field. in other words I do not want one of the calculated field not visible to a particular Role Member..

|||

Now how can I control the security of these calculated members. meaning, I do not want the calculated field to be available to a pariculat role?

This is not possible in AS2005.

|||

Thanks Mosha, Is there any other work around with which I can make the caluclated fields available/ visible only to a set of users.

I have a calculated field of $'s which I do not want to be visible to all the memebers. It should be visible only to Managers who are members of Managers Role.

|||You should define it as a real member of the dimension then. Since the fact table won't have keys related to that member - after processing it will be empty - so you are not paying anything in the space. Then inside MDX Script you can overwrite it with any MDX expression you want, just like you do with the calculated members. But now since it is a real member, you can secure it in a role.|||

Another option is to add Cell Data security to the measure. The following article shows details of how to add security to only allow users to use a specific measure.

http://msdn2.microsoft.com/en-us/library/aa933600(SQL.80).aspx

This works for calculated members as well.

In the Cell Data tab of the Role editor, tick 'Enable read permissions', and add a statement referring to the measures the user IS allowed to use. This will then disallow access to any other measures.

e.g.

If we have 3 measures:

MemberCount
SalesCount
MemberPay

And want to diallow access to the MemberPay measure for a specific role, we could use the following statement in the Cell Data page:

Measures.CurrentMember.Name = "MemberCount" or Measures.CurrentMember.Name = "SalesCount"

Thursday, February 9, 2012

Analysis Services 2005 Lock-up on Calculated Measures

AS 2005/VS 2005 is locking-up when I try to go to the calculated measures tab. It uses some CPU and I think a lot of I/O. My only way out is to close VS.

Everything else is working. I looked at the XML and it looked OK to me (naive me).

I have written out the xml and created another db/cube and the problem came along with the xml.

I'm stuck.

Tom

The calculation tab in BIDS (VS) has to do a parse of the script to display it in the UI, so this would suggest that there is something in the script that is giving it issues.

Try creating another database/cube using the xmla as you did before, but also do the following:

search for the <MDXScript></MDXScript> tags and copy the contents into another file for safe keeping|||

I tried that - no luck.

Also tried a transplant from a OK cube. I'm guessing it is not the mdx scripts.

It happens when I try to go to the translate tab and the perspective tab too (in addition to the calculated tab).

I also re-installed SS/AS/RP/IS 2005; (that was a train wreck)

I am still stuck; I'll try other tabs and maybe get a clue. Any assistance would be appreciated.

|||

OK, I did the previous post off the top of my head and as you must have figured out, you actually need to remove the data under the <MDXScript><Commands><Command><Text> Node to remove the calculation script.

The other structure under the MDXScript node is the <CalculationProperties> - this is where translations and display folders for the calculated members are stored so it might be this data that is causing your issue. This is the only data that I can think of at the moment that would appear in all three tabs that are causing you issues.

If you have not already, you could try the same approach as before, except you can actually remove all the calculation property nodes leaving just empty <CalculationProperties></CalculationProperties> tags.

|||

Got it!

Was behind on SQL server/AS updates and VS updates.

When I updated to cummulative SQL server updates and VS latest update the problem was resolved.

Thank you for your time and your input.

Tom