Thomas Pagel BI Blog

Microsoft BI Technology & more

<August 2008>
SuMoTuWeThFrSa
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456


Navigation

SSIS Blogs

SSRS Blogs

SSAS Blogs

Other SQL Server Links

Subscriptions

Post Categories



Currency Conversion with SSAS

Microsoft tried to include best practices and other common tasks you had to implement on your own in Analysis Services 2000 in the new 2005 release by wizards. What do I have to say – THANKS for that! However there are some problems arising…

One is the currency conversion… Microsoft added a nice wizard for that. It handles the currency table and all the exchange rates. The result is a calculation added automatically in the cube. Here’s an example:

// <Currency conversion>

            // Currency conversion wizard generated script.           

            // Currency conversion generated on: Freitag, 24. Juni 2005 11:44:51

            // by user: cthiell    

            // Currency conversion type: OneToMany  

            // Selected members to be converted: Kosten des Einkaufs  

            // Please be aware that any changes that you decide to make to it may be overridden the next time you run the Currency Conversion wizard again.

            // All currency conversion formulas are calculated for the non pivot currency and at leaf of the time dimension

            Scope ( { Measures.[Price]} );  

                  Scope( Leaves([Date]) ,

                        Except([Reporting Currency].[Currency].Members, [Reporting Currency].[Currency].[Currency].[EUR]));  

                // This section overrides the Pivot Currency values with the Converted value for each selected measures/account members/account type members needing to be converted with Measure rate FAKT KURS - FAKT KURS KURS

                // LinkMember is used to reference the currency from the source currency dimension in the rate cube. 

                Scope( { Measures.[Price]} );  

                       This = (Measures.[Rate], LinkMember([Reporting Currency].[Currency].CurrentMember, [Currency].[Currency])) * [Reporting Currency].[Currency].[EUR];  

                End Scope;  

                  End Scope;  

So what does this script do? It simply exchanges the calculation of the measure “Price” for all currencies when the currency selected is not the currency the measure is stored in. So if you use “USD” instead of “EUR” each day’s value is multiplied by each day’s conversion rate (which is 100% correct) and then aggregated.

OK, so what’s the problem? Well, I see two problems:

  • If you have any calculated measures based on measures working with currency conversions, the calculated measures don’t work anymore. This might be a problem of my limited MDX knowledge but at the moment this is a fact for me…
  •  If you have a complex cube you will notice significant performance degradation. Why? Well, that’s easy… Instead of retrieving the year’s sales (that’s already pre-aggregated) each day sales is queried, multiplied by the conversion rate and then aggregated... This is really a significant overhead…

I didn’t try to use a different approach… This would be that I change the Cube’s underlying Data Source view to do a cross join of the fact table and the currency conversion table. So I would have a fact record per currency with the correct conversion rate. This would end up in a much bigger cube but performance should be better (since everything can be aggregated) and calculated measures should be no problem anymore.

Any comments are very much appreciated…

 

 

Thomas

posted on Sunday, July 24, 2005 2:34 PM by tpagel


# re: Currency Conversion with SSAS @ Friday, July 29, 2005 2:51 AM

Thomas - I wanted to follow up both problems you raised:

1. Can you clarify what is the problem with calculated measures ? Why wouldn't they work anymore ? I actually think, that the opposite is true - they will work perfectly :)

2. The reason the MDX Script scopes on Leaves of Time is because rates change daily - therefore the calculation must be computed for every day and then aggregated.

mosha

# re: Currency Conversion with SSAS @ Monday, August 01, 2005 9:33 AM

Mosha,

I understand the reason why the performance is not perfect... The calculation is correct and maybe that's the only way it can be resolved. However this is why reports running a minute (this is already a long time, but it's quite complex stuff...) now take nearly forever... You commented on my other post that there might be a performance improvement in a future CTP - Well, I don't loose hope anytime ;-)

Now to the problem with the calculated measures:

If you use the currency conversion wizard (OneToMany) you get a script like this (for the physical Measure „Rechnungswert“):

// <Currency conversion>



// Currency conversion wizard generated script.

// Currency conversion generated on: Freitag, 24. Juni 2005 11:44:51

// by user: cthiell

// Currency conversion type: OneToMany

// Selected members to be converted: Kosten des Einkaufs

// Please be aware that any changes that you decide to make to it may be overridden the next time you run the Currency Conversion wizard again.



// All currency conversion formulas are calculated for the non pivot currency and at leaf of the time dimension

Scope ( { Measures.[Rechnungswert]} );



Scope( Leaves([Datum]) ,

Except([Reporting Currency].[Waehrung].Members, [Reporting Currency].[Waehrung].[Waehrung].[EUR]));









// This section overrides the Pivot Currency values with the Converted value for each selected measures/account members/account type members needing to be converted with Measure rate FAKT KURS - FAKT KURS KURS

// LinkMember is used to reference the currency from the source currency dimension in the rate cube.

Scope( { Measures.[Rechnungswert]} );



This = (Measures.[FAKT KURS - FAKT KURS KURS], LinkMember([Reporting Currency].[Waehrung].CurrentMember, [Waehrung].[Waehrung])) * [Reporting Currency].[Waehrung].[EUR];



End Scope;







End Scope;

// Measures



// End of the currency conversion wizard generated script

// </Currency conversion>

// Leaves of time and non pivot currency

End Scope;



You see that “EUR” is the currency all invoices are stored in. This works OK so far.

So you add some calculated measures:

CREATE MEMBER CURRENTCUBE.[MEASURES].[Rechnungswert LJ]

AS ([Datum].[Jahr].CurrentMember, [Measures].[Rechnungswert]),

FORMAT_STRING = "Currency",

VISIBLE = 1;

CREATE MEMBER CURRENTCUBE.[MEASURES].[Rechnungswert VJ]

AS (ParallelPeriod([Datum].[Jahr].[Jahr],1,[Datum].[Jahr].CurrentMember), [Measures].[Rechnungswert]),

FORMAT_STRING = "Currency",

VISIBLE = 1;

So these calculated members should give us the current year’s “Rechnungswert” (Rechnungswert LJ) and the previous year’s “Rechnungswert” (Rechnungswert VJ).

This works fine with “EUR” selected as “Reporting Currency” but not with each other currency.

I have a screenshot for this if you don't believe me ;-)) I would be happy to reproduce that with Adventureworks but it doesn't have currency conversion (one to many) enabled...


Thanks for the Feedback,



Thomas

tpagel

# SSAS: News about Currency Conversion @ Wednesday, August 31, 2005 10:48 AM

OK, I really don’t know why, but my statements about currency conversion (http://sqljunkies.com/WebLog/tpagel/archive/2005/07/24/16196.aspx)...

Anonymous




Powered by Dot Net Junkies, by Telligent Systems