SSAS MDX 查询中的多维度条件不起作用

发布于 2025-01-10 02:00:36 字数 1766 浏览 5 评论 0原文

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

输入图片此处描述

我的需要是使用 MDX 根据具有两个不同维度的两个条件获取度量值。

在此示例数据中,我需要获取经销商销售额值,其中Title维度的值等于销售代表并且Gender维度的值等于Male条件。

我尝试使用 Case 语句和 IIF() 函数在 MDX 中可用,但不起作用。

请查找我尝试过使用不同功能的查询。

使用 Case 语句:

WITH MEMBER [Measures].[Expression1] AS
CASE WHEN [Employee].[Title].CURRENTMEMBER.MEMBERVALUE = "Sales Representative" THEN (CASE
WHEN [Employee].[Gender].CURRENTMEMBER.MEMBERVALUE = "Male"
THEN [Measures].[Reseller Sales Amount] ELSE 0 END)ELSE 0 END select [Measures].[Expression1] on Columns from [Sales Targets]

使用 IIF() 函数:

WITH MEMBER [Measures].[Expression1] AS
IIF( [Employee].[Title].CURRENTMEMBER.MEMBERVALUE = "Sales Representative" AND [Employee].[Gender].CURRENTMEMBER.MEMBERVALUE = "Male",
[Measures].[Reseller Sales Amount], 0)
SELECT{
[Measures].[Expression1]} ON COLUMNS FROM [Sales Targets] CELL PROPERTIES VALUE, FORMATTED_VALUE, FORMAT_STRING

我得到的两个查询的结果都是 0。

在此处输入图像描述

任何人都可以指导我使用 MDX 获得正确的结果吗?

I Am having the following data in my SSAS cube.

enter image description here

My need is to get the value of the measure based on two conditions with two different dimensions using the MDX.

In this example data, I need to get the Reseller Sales Amount value where the value of Title dimension is equal to Sales Representative and the value of the Genderdimension is equal to Male condition.

I have tried to achieve the requirement with the Case statement and IIF() function available in the MDX but it is not working.

Please find the queries I have tried with different functions.

Using Case statement:

WITH MEMBER [Measures].[Expression1] AS
CASE WHEN [Employee].[Title].CURRENTMEMBER.MEMBERVALUE = "Sales Representative" THEN (CASE
WHEN [Employee].[Gender].CURRENTMEMBER.MEMBERVALUE = "Male"
THEN [Measures].[Reseller Sales Amount] ELSE 0 END)ELSE 0 END select [Measures].[Expression1] on Columns from [Sales Targets]

Using IIF() function:

WITH MEMBER [Measures].[Expression1] AS
IIF( [Employee].[Title].CURRENTMEMBER.MEMBERVALUE = "Sales Representative" AND [Employee].[Gender].CURRENTMEMBER.MEMBERVALUE = "Male",
[Measures].[Reseller Sales Amount], 0)
SELECT{
[Measures].[Expression1]} ON COLUMNS FROM [Sales Targets] CELL PROPERTIES VALUE, FORMATTED_VALUE, FORMAT_STRING

The result that I am getting for both queries is 0.

enter image description here

Can anyone please guide me to get the proper result using MDX?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

远昼 2025-01-17 02:00:36

您可以使用 元组< /a> 直接在计算的度量中:

WITH MEMBER [Measures].[Expression1] AS
([Measures].[Reseller Sales Amount], [Employee].[Title].[Sales Representative], [Employee].[Gender].[Male])
select [Measures].[Expression1] on Columns 
from [Sales Targets]

或者如果您希望它应用于查询中的所有单元格,您可以将元组放在 where 子句中:

Select [Measures].[Reseller Sales Amount] on Columns 
from [Sales Targets]
where ([Employee].[Title].[Sales Representative], [Employee].[Gender].[Male])

You can use a Tuple either directly in the calculated measure:

WITH MEMBER [Measures].[Expression1] AS
([Measures].[Reseller Sales Amount], [Employee].[Title].[Sales Representative], [Employee].[Gender].[Male])
select [Measures].[Expression1] on Columns 
from [Sales Targets]

Or you can put a Tuple in the where clause if you want it to apply to all cells in the query:

Select [Measures].[Reseller Sales Amount] on Columns 
from [Sales Targets]
where ([Employee].[Title].[Sales Representative], [Employee].[Gender].[Male])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文