I'm currently struggle with an issue and I hope you help with that.

I need to dynamically associate an attribute of a dimension in my SSAS cube (multidimensional) based on a calculation performed on the cube itself.

Simplifing, based on a date selected by the user, I have a calculation (already done) that returns the number of days that type of material is in stock. With that value I want to return an attribute based on a range of values.

for example:

Nr_Days_Calculated = 80 


ID  INI  END        DSC

1     0  90         TextA

2    91  180        TextB

3   181  99999      TextC

Result : 1 - TextA

Can anyone please help me? Thanks for your attention.


1 Answers


It's doable if your dimension also has dynamic calculations. Let me show you another example, but idea is the same.

I have a dimension [Repeat Customers], if a customer (identified by email) signed in the second, third, fourth time - move this customer to appropriate member of this dimension.

First, create dimension with one default member.

Second, add several empty members:

(you can skip it, because dim members are materialized in your case)

CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[One] as NULL;      
CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[Two] as NULL;      
CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[Three] as NULL;      
CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[Four] as NULL;      
CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[Five] as NULL;      
CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[6+] as NULL;      
CREATE MEMBER CURRENTCUBE.[Repeat Customers].[Repeat Customers].[All].[N/A] as NULL; 

Third, add their calculations:

SCOPE([Repeat Customers].[Repeat Customers].[All].[One],[Measures].[Count]);      
THIS=Count(Filter([Email].[Email].Members,([Measures].[Count],[Repeat Customers].[Repeat Customers].&[0])=1));      
END SCOPE;      

SCOPE([Repeat Customers].[Repeat Customers].[All].[Two],[Measures].[Count]);      
THIS=Count(Filter([Email].[Email].Members,([Measures].[Count],[Repeat Customers].[Repeat Customers].&[0])=2));      
END SCOPE;      


SCOPE([Repeat Customers].[Repeat Customers].[All].[6+],[Measures].[Count]);      
THIS=Count(Filter([Email].[Email].Members,([Measures].[Count],[Repeat Customers].[Repeat Customers].&[0])>=6));      

SCOPE([Repeat Customers].[Repeat Customers].[All].[N/A],[Measures].[Count]);      
THIS=([Measures].[Count],[Repeat Customers].[Repeat Customers].&[0])
 [Repeat Customers].[Repeat Customers].[All].[One]
,[Repeat Customers].[Repeat Customers].[All].[Two]
,[Repeat Customers].[Repeat Customers].[All].[Three]
,[Repeat Customers].[Repeat Customers].[All].[Four]
,[Repeat Customers].[Repeat Customers].[All].[Five]
,[Repeat Customers].[Repeat Customers].[All].[6+]



I think your filter has to use >= and <= Nr_Days_Calculated. But not sure which measure are you trying to show. Is 1 - TextA related to [Measures].[Nr_Days_Calculated]? If yes, we are good, just use your measure and SUM or else as aggregate instead of Count() in my case.

This is not the best performance solution (because of dynamic calculation), but still it works. Hope it helps.