简体   繁体   English

基于SSAS计算量度的SSAS维度属性

[英]SSAS Dimension Attribute based on a SSAS calculated measure

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. 我需要根据对多维数据集本身执行的计算来动态关联SSAS多维数据集(多维)中维度的属性。

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 

DIMENSION: 尺寸:

ID  INI  END        DSC

1     0  90         TextA

2    91  180        TextB

3   181  99999      TextC

Result : 1 - TextA 结果: 1 - TextA

Can anyone please help me? 谁能帮帮我吗? Thanks for your attention. 感谢您的关注。

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));      
END SCOPE;

SCOPE([Repeat Customers].[Repeat Customers].[All].[N/A],[Measures].[Count]);      
THIS=([Measures].[Count],[Repeat Customers].[Repeat Customers].&[0])
-SUM({
 [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+]
},[Measures].[Count]);      
END SCOPE;

Output: 输出:

DynamicDim

I think your filter has to use >= and <= Nr_Days_Calculated. 我认为您的过滤器必须使用> =和<= Nr_Days_Calculated。 But not sure which measure are you trying to show. 但是不确定您要显示哪种度量。 Is 1 - TextA related to [Measures].[Nr_Days_Calculated] ? 1 - TextA[Measures].[Nr_Days_Calculated]相关[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. 如果是,那么我们很好,请仅使用您的度量和SUM或以聚合的方式代替Count()。

This is not the best performance solution (because of dynamic calculation), but still it works. 这不是最佳性能解决方案(由于动态计算),但仍然有效。 Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM