别名MDX查询SSAS [英] Alias MDX Query SSAS

查看:150
本文介绍了别名MDX查询SSAS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WITH MEMBER [Measures].[NetPromoterScore] AS (IIF(([Measures].[Net Promoter Score] = 1/0 OR 
[Measures].[Net Promoter Score] = -1/0 OR ISEMPTY([Measures].[Net Promoter Score]) 
OR [Measures].[Avg Revenue Per Unit] = 1/0 OR [Measures].[Avg Revenue Per Unit] = -1/0 OR 
ISEMPTY([Measures].[Avg Revenue Per Unit]) ), NULL, [Measures].[Net Promoter Score])) 

MEMBER [Measures].[AvgRevenuePerUnit] AS (IIF(([Measures].[Net Promoter Score] = 1/0 
OR [Measures].[Net Promoter Score] = -1/0 OR ISEMPTY([Measures].[Net Promoter Score]) 
OR [Measures].[Avg Revenue Per Unit] = 1/0 OR [Measures].[Avg Revenue Per Unit] = -1/0 
OR ISEMPTY([Measures].[Avg Revenue Per Unit]) ), NULL, [Measures].[Avg Revenue Per Unit]))

SELECT NON EMPTY
       { {[Measures].[NetPromoterScore],[Measures].[AvgRevenuePerUnit]} }
       ON COLUMNS ,
       NON EMPTY
       {{Hierarchize(DrilldownLevel({[Roles].[Enterprise Role].[ALL]}))}}
       DIMENSION  PROPERTIES MEMBER_CAPTION,  MEMBER_UNIQUE_NAME
       ON ROWS
  from Enterprise 
 WHERE (FILTER( [Employees].[EID].[EID],[Measures].[Avg Revenue Per Unit]> 700),
        {[Areas].[Area].&[3]},
        {[Markets].[Market].&[1]},{[Regions].[Region].&[2]},{[Locations].[Location].&[6],[Locations].[Location].&[6]},
        {[Dates].[Date].&[20130219]:[Dates].[Date].&[20130318]})

如您所见,我在[Net Promoter Score]列名称中使用[NetPromoterScore]作为别名,在[Avg Per单位收入]列名称中使用[AvgRevenuePerUnit]作为别名.但是在我的C#代码中,使用的名称是[Net Promoter Score]和[每单位平均收入],我无法使用新的别名来更改这些先前的名称,因为我必须在数十个文件中进行更改,然后我必须测试整个应用程序.我可以在上面的查询中两次别名以获取相同的先前列名吗,还是可以不使用别名从上面的查询中获取相同的结果?

As you see I have aliased [Net Promoter Score] column name with [NetPromoterScore] and [Avg Revenue Per Unit] column name with [AvgRevenuePerUnit]. But in my C# code, the names used are [Net Promoter Score] and [Avg Revenue Per Unit] and I can't change these previous name with new aliased name because I have to make changes in dozens of files and then I have to test whole application. Can I alias twice in the query above to get same previous column names or can I without aliasing get the same result from the query above?

推荐答案

实际上,就MDX而言,您没有为成员添加别名,而是创建了新成员.

Actually, in the sense of MDX, you have not aliased the members, but created new members.

我看到两种解决方法:

  1. 将这些计算移至多维数据集计算脚本,即i. e.改名 多维数据集中的原始度量,并定义计算的度量 与您所需的名称和您具有的相同计算 在您的查询中.然后,您将进行原始的重命名措施 无形的.在我看来,这将是最好的解决方案 让每个多维数据集用户都能从改进中受益,而不会中断 外部代码或查询.

  1. Move these calculations to the cube calculation script, i. e. rename the original measures in the cube, and define calculated measures with the name that you need and the same calculation that you have in your query. You would then make the original renamed measures invisible. This would be the best solution in my eyes, as it would let every cube user benefit from the improvement, without breaking external code or queries.

取决于您在C#代码中引用度量的准确程度 (您没有发布示例),可以只使用caption属性 的措施,一. e.重新编写成员定义,如下所示:

Depending on how exactly you reference the measures in your C# code (you did not post samples), you could just use the caption property of the measures, i. e. re-write the member definitions as follows:

有成员[措施].[NetPromoterScore]作为IIF(...),CAPTION =净发起人得分" 成员[度量].[AvgRevenuePerUnit]作为IIF(...),CAPTION ='每单位平均收入'

WITH MEMBER [Measures].[NetPromoterScore] AS IIF(...), CAPTION = 'Net Promoter Score' MEMBER [Measures].[AvgRevenuePerUnit] AS IIF(...), CAPTION = 'Avg Revenue Per Unit'

这篇关于别名MDX查询SSAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆