Showing posts with label requirement. Show all posts
Showing posts with label requirement. 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 for DBA's.

A lot of job postings these days for SQL DBA's list the requirement of
Analysis Services. Not having any experience with it I'm wondering what
exactly is meant? Of course its going to vary from company to company, but I
really have no clue what they mean in general? Is it cube design? MDX query
writing? Simply backing up? To be clear, Im asking in regards specificically
for a DBA, not a Developer.
TIA, ChrisR
Chris - not that I'm an expert at all, but I have done 2 short contracts in
AS/SQL and might share these experiences. In both I had to design the cubes
and staging database structure and manage the population of the staging
database (DTS). The determination of fact granularity and measures takes
ages and I was expected to do that. All in all this was the main part of my
work. We created some sample reports using Excel PivotTables and ProClarity
and once they were up and running they wanted to take time to design the
rest of the queries. I showed them a little MDX because it was of interest
to me and the tools seem slightly limited out of the box ("Generate" was one
particularly useful function which ProClarity couldn't do at the time) but
in my 2 roles MDX wasn't a priority and unless you are using it every day
you're unlikely to become good at it anyway IMHO. Since then I've met a guy
at a large multinational insurance firm who does all their data warehousing
using AS and he has never touched MDX at all. My guess therefore is that
cube design and population are the main skills, and for report-writing it is
important to have familiarity with the main front-end tools - (as far as I
know Cognos and ProClarity).
Cheers,
Paul Ibison

Analysis Services for DBA's.

A lot of job postings these days for SQL DBA's list the requirement of
Analysis Services. Not having any experience with it I'm wondering what
exactly is meant? Of course its going to vary from company to company, but I
really have no clue what they mean in general? Is it cube design? MDX query
writing? Simply backing up? To be clear, Im asking in regards specificically
for a DBA, not a Developer.
TIA, ChrisRChris - not that I'm an expert at all, but I have done 2 short contracts in
AS/SQL and might share these experiences. In both I had to design the cubes
and staging database structure and manage the population of the staging
database (DTS). The determination of fact granularity and measures takes
ages and I was expected to do that. All in all this was the main part of my
work. We created some sample reports using Excel PivotTables and ProClarity
and once they were up and running they wanted to take time to design the
rest of the queries. I showed them a little MDX because it was of interest
to me and the tools seem slightly limited out of the box ("Generate" was one
particularly useful function which ProClarity couldn't do at the time) but
in my 2 roles MDX wasn't a priority and unless you are using it every day
you're unlikely to become good at it anyway IMHO. Since then I've met a guy
at a large multinational insurance firm who does all their data warehousing
using AS and he has never touched MDX at all. My guess therefore is that
cube design and population are the main skills, and for report-writing it is
important to have familiarity with the main front-end tools - (as far as I
know Cognos and ProClarity).
Cheers,
Paul Ibison

Analysis Services for DBA's.

A lot of job postings these days for SQL DBA's list the requirement of
Analysis Services. Not having any experience with it I'm wondering what
exactly is meant? Of course its going to vary from company to company, but I
really have no clue what they mean in general? Is it cube design? MDX query
writing? Simply backing up? To be clear, Im asking in regards specificically
for a DBA, not a Developer.
TIA, ChrisRChris - not that I'm an expert at all, but I have done 2 short contracts in
AS/SQL and might share these experiences. In both I had to design the cubes
and staging database structure and manage the population of the staging
database (DTS). The determination of fact granularity and measures takes
ages and I was expected to do that. All in all this was the main part of my
work. We created some sample reports using Excel PivotTables and ProClarity
and once they were up and running they wanted to take time to design the
rest of the queries. I showed them a little MDX because it was of interest
to me and the tools seem slightly limited out of the box ("Generate" was one
particularly useful function which ProClarity couldn't do at the time) but
in my 2 roles MDX wasn't a priority and unless you are using it every day
you're unlikely to become good at it anyway IMHO. Since then I've met a guy
at a large multinational insurance firm who does all their data warehousing
using AS and he has never touched MDX at all. My guess therefore is that
cube design and population are the main skills, and for report-writing it is
important to have familiarity with the main front-end tools - (as far as I
know Cognos and ProClarity).
Cheers,
Paul Ibison

Analysis Services for DBAs.

A lot of job postings these days for SQL DBA's list the requirement of Analysis Services. Not having any experience with it I'm wondering what exactly is meant? Of course its going to vary from company to company, but I really have no clue what they mean in general? Is it cube design? MDX query writing? Simply backing up? To be clear, Im asking in regards specificically for a DBA, not a Developer.

TIA, ChrisRit really annoys me how microsoft seems to change the name for this every year or 2. data warehousing, OLAP, analysis services, business intelligence etc... It really throws the recruiters off and makes me have to put what I think are redundant statements on my resume. do you know how to implement a denormalized copy of your data for reporting purposes in such a such version of the product?|||Yes. But I don't know much about AS, hence the question.|||it really annoys me how microsoft seems to change the name for this every year or 2.

how else would you know it's time to upgrade?|||ANALYSIS SERVICES IS NOT DATA WAREHOUSING!

(Just thought that would pair well with me sig...)|||does that mean AS is a star schema? ;)|||Logically, no.

For instance:

COW PIES ARE NOT DATA WAREHOUSES!

This does not imply that cow pies are star schemas. Neither does it assert that data warehouses are not cow pies, which, in fact, many of the ones based upon star schemas are...|||heh, i was just kidding. a dumb joke.|||the blindman is being funny too. his tone can just be misconstrued some times.

I am glad I am not the only one breaking the super bowl sabbath. Damn last minute requirements changes. My numbers are not balancing. Missing about $375 out of 500K in my testing environment. this friggin' thing was working before I got the new requirements Friday after lunch. Going nuts. At least I am at home on the couch working on it...|||that's nothing - one of my ex-girlfriends used to be a bank teller. she once told me the tellers there used to be up or down up to 1k after a *single* day. :)|||the blindman is being funny too. his tone can just be misconstrued some times.They have yet to invent an emoticon to represent the nuances of my posts.