如何将当前成员值与MDX查询中的先前成员值进行比较?

发布于 2025-01-17 13:20:07 字数 1292 浏览 3 评论 0 原文

我的 SSAS 多维数据集中有以下数据

在此处输入图像描述

我需要使用 MDX查询。

在此示例数据中,当 Id 列的当前值不等于之前的值时,我需要获取 Weight 值作为 Result Id 列,否则为 0。

请在下面的屏幕截图中查找公式和示例结果以供参考。 输入图片此处描述

我尝试使用 PrevMember 函数在 Mdx 中可用,但它不起作用。

请找到我尝试过的查询:

WITH     MEMBER [Measures].[Expression1] AS IIF([Id].CURRENTMEMBER = [Id].CURRENTMEMBER.PrevMember,0,[Weight])  
SELECT{ [Measures].[Expression1]} ON COLUMNS ,
NONEMPTY((TOPCOUNT( (Order((([class].[Id].[Id].ALLMEMBERS)),[class].[Id].CurrentMember.MemberValue,ASC)),101)),
{ [Measures].[Expression1]}) ON ROWS FROM [Model] CELL PROPERTIES VALUE, FORMATTED_VALUE, FORMAT_STRING

查询得到的结果是

在此处输入图像描述

I am having the following data in my SSAS cube

enter image description here

I need to get the value based on a comparison between the current value and the previous value using MDX query.

In this example data, I need to get the Weight value as Result when the current value of Id column is not equal to the previous value of Id column otherwise 0.

Please find the formula and the sample result in the below screenshot for reference.
enter image description here

I have tried to achieve the requirement using PrevMember function available in the Mdx but it is not working.

Please find the query I have tried:

WITH     MEMBER [Measures].[Expression1] AS IIF([Id].CURRENTMEMBER = [Id].CURRENTMEMBER.PrevMember,0,[Weight])  
SELECT{ [Measures].[Expression1]} ON COLUMNS ,
NONEMPTY((TOPCOUNT( (Order((([class].[Id].[Id].ALLMEMBERS)),[class].[Id].CurrentMember.MemberValue,ASC)),101)),
{ [Measures].[Expression1]}) ON ROWS FROM [Model] CELL PROPERTIES VALUE, FORMATTED_VALUE, FORMAT_STRING

The result am getting for the query is

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文