Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1318
  • Last Modified:

SSAS :: MDX :: Scope function

Hey all,
My problem:
I'm trying to create a scope function that calculates exchange rates based on a date and currency AND a specified rate.

I have this working fine, but within my scope function I want to say - if Dimension.Attribute.member = "Latest" then use FXRate 1 otherwise use FXRate 2.

Now I even have that "working"... BUT that only works if the member is in my dataset... i.e. I can't use it as a parameter\filter.
I don't want to have to tell the users "you always have to have LatestFlag in every report... just hide the column"
I want to give the user the ability to set the report parameters before he starts analysing the data.

So here's a snippet of my code so far:
Scope ( { Measures.[Amount]} );      
Scope( Leaves([ExchangeDate]), [Reporting Currency].[USD],Leaves([Currency]));      
Scope( { Measures.[Amount]});    

This = iif(
[Latest Flag].[Flag].CURRENTMEMBER.name = "Yes",
[Reporting Currency].[Local] / Measures.[Rate2],
[Reporting Currency].[Local] / Measures.[Rate]
);              

End Scope;  
End Scope;
End Scope;

I suspect I need to use another Scope instead of the iif - but I'm not sure how to implement.
Any ideas?

Oh it's probably important to note.
The FXRate table has two rates.
Rate is updated daily.
Rate2 is repeated for every currency everyday.
So irrevelant of the date, Rate2 will always be the latest rate for that currency.
The LatestFlag dimension is merely a table with yes and no and doens't have any relationship to any other table.
I'm just using it as a filter.

There is a flag on the FX table too - but I'm not using this as I need the date to be considered if it's not the latest rate.
0
_Tups
Asked:
_Tups
1 Solution

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now