我是MDX的新手,需要一些帮助。在SSRS中,我有一个从SSAS多维数据集中提取的数据集。数据集始终包含六个月的数据。我需要做的是比较max(timeID)的值和第二个max(timeID)的值以及max(timeID)>的值。第二个最大值(timeID)的值比箭头在指标等中上升......
因此,对于下面的数据集,我将减去20130201的值,即8 20130301的值为10.结果为正数,指标为向上的绿色箭头。如果它是0那么它将是直的,如果是负的,箭头将是红色并指向下方。我理解如何处理指标 - 这不是问题。这是我需要帮助的MDX。
20130201 8 20130301 10 20121201 4
我可以在SQL中编写它,它看起来像这样。
Select Item, case when sum(Time1ContentCount) > sum(Time2ContentCount) then 3 when sum(Time1ContentCount) = sum(Time2ContentCount) then 2 when sum(Time1ContentCount) sum(Time2ContentCount) then 1 end as Indicator, sum(Time1ContentCount) as Time1Count, sum(Time2ContentCount) as Time2Count from (Select timeID, dc.Item, Case when timeID = (Select max(timeID) from FactUsage) then count(fu.Contentid) else 0 END as Time1ContentCount, Case when timeID = (Select max(timeID) from FactUsage where timeID <>(Select max(timeID) from FactUsage)) then count(fu.Contentid) else 0 END as Time2ContentCount from factUsage fu INNER JOIN dimContent dC on dc.ContentID = fu.ContentID WHERE TimeID in (Select distinct top 6 timeid from factUsage order by timeID desc) Group by timeID, Item) a group by Item
非常感谢你的帮助!
编辑: 我将语句改为如下所示:
WITH Member MEASURES.Indicator AS (
IIF(( [Measures].[Activity], [Time].[Time ID].LastChild ) >
( [Measures].[Activity], [Time].[Time ID].LastChild.PrevMember),3,
(IIF(([Measures].[Activity], [Time].[Time ID].LastChild ) =
([Measures].[Activity], [Time].[Time ID].LastChild.PrevMember), 2,1))))
SELECT {Measures.Indicator} on 0
FROM [DW]
当我将其作为SSMS中的多维数据集的查询运行时,它可以工作,但我试图将它放在指标中,但这不起作用。只是添加IIF语句也不起作用。当我试图将它添加到查询或立方体本身时,我可以从那里拉出它错误输出内存不足错误。
答案 0 :(得分:0)
我不知道您可以在MDX表达式中编辑多少 - 或者在报表生成器中编辑,但为了获得系列中两个值之间的差异,您可以创建一个度量(在报表中),这是差异在CurrentMember和PrevMember之间。由于时间序列(timeid)按键排序,因此它将始终按正确的顺序排列(或者您的架构和架构需要返工)
基本上,你可以这样做:
WITH
MEMBER MEASURES.GrowthTime AS (
( [Measures].[Value], [TimeID].CurrentMember ) -
( [Measures].[Value], [TimeID].PrevMember )
)
MEMBER MEASURES.GrowthRatio AS (
( [Measures].[Value], [TimeID].CurrentMember ) /
( [Measures].[Value], [TimeID].PrevMember )
)
SELECT { Measures.Value, Measures.GrowthTime, Measures.GrowthRatio } on 0,
[TimeID].CHILDREN on 1
FROM Cube
这是伪的,因为我不知道你的立方体结构。对于TimeID,您可能需要[DimensionName].[AttributeName].CurrentMember
和PrevMember