gpt4 book ai didi

sql-server - 多个语句以防 MDX

转载 作者:行者123 更新时间:2023-12-03 21:24:07 26 4
gpt4 key购买 nike

我必须编写将显示在列上并将行分为三组的 MDX。第一组以数字区分,第二组以属性区分,第三组是休息不适合的地方。

到目前为止,我的代码看起来像这样:

case 
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "4254255527" then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "2752637520" then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "5637839739" then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "9378793737" then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "3789789397" then "ABC"
when [Document].[Document series].CURRENTMEMBER.MEMBERVALUE = "XYZ" then "XYZ"
else "Rest"
end

但我每次都在“休息”。

我该如何纠正?

编辑:再次尝试但仍然无效:

case 
when [Customer].[Customer's Document].[&5196189651] then "ABC"
when [Customer].[Customer's Document].[&7885181585] then "ABC"
when [Customer].[Customer's Document].[&7511535861] then "ABC"
when [Customer].[Customer's Document].[&4742575277] then "ABC"
when [Customer].[Customer's Document].[&7272727272] then "ABC"
when [Customer's Document].[Document Series].[&CHP] then "XYZ"
else "Rest"
end

最佳答案

我感觉你更想做如下事情:

WITH 
SET [ABC] AS
{
[Customer].[Customer's Document].&[5196189651]
,[Customer].[Customer's Document].&[7885181585]
,[Customer].[Customer's Document].&[7511535861]
,[Customer].[Customer's Document].&[4742575277]
,[Customer].[Customer's Document].&[7272727272]
}
MEMBER [Customer].[All].[ABC] AS
Aggregate([ABC])
MEMBER [Customer].[All].[XYZ] AS
[Customer].[Customer's Document].[Document Series].&[CHP]
SET [REST] AS
Except
(
[Customer].[Customer's Document].MEMBERS
,[ABC]
)
MEMBER [Customer].[All].[Rest] AS
Aggregate([REST])
SET [FINAL] AS
{
[Customer].[All].[ABC]
,[Customer].[All].[XYZ]
,[Customer].[All].[Rest]
}
SELECT
[FINAL] ON 1
,{[Measures].[Amount]} ON 0
FROM [YourCube];

或者可能是以下内容:

WITH 
SET [ABC] AS
{
[Customer].[Customer's Document].&[5196189651]
,[Customer].[Customer's Document].&[7885181585]
,[Customer].[Customer's Document].&[7511535861]
,[Customer].[Customer's Document].&[4742575277]
,[Customer].[Customer's Document].&[7272727272]
}
MEMBER [Customer].[All].[ABC] AS
Aggregate([ABC])
MEMBER [Customer].[All].[XYZ] AS
[Customer].[Customer's Document].[Document Series].&[CHP]
SET [REST] AS
Except
(
[Customer].[Customer's Document].MEMBERS
,{
[ABC]
,[Customer].[Customer's Document].[Document Series].&[CHP]
}
)
MEMBER [Customer].[All].[Rest] AS
Aggregate([REST])
SET [FINAL] AS
{
[Customer].[All].[ABC]
,[Customer].[All].[XYZ]
,[Customer].[All].[Rest]
}
SELECT
[FINAL] ON 1
,{[Measures].[Amount]} ON 0
FROM [YourCube];

编辑

只是一个警告 - 在接受的答案中有以下 mdx:

case 
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "4254255527" then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "2752637520" then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER.MEMBERVALUE = "5637839739" then "ABC"
...
...

这可能被标记为解决方案,但它不是很好的 mdx。在这种情况下,应使用 IS 运算符:

case 
when [Customer].[Customer's Document].CURRENTMEMBER IS
[Customer].[Customer's Document].[Customer's Document].&[4254255527] then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER IS
[Customer].[Customer's Document].[Customer's Document].&[2752637520] then "ABC"
when [Customer].[Customer's Document].CURRENTMEMBER IS
[Customer].[Customer's Document].[Customer's Document].&[5637839739] then "ABC"
...
...

关于sql-server - 多个语句以防 MDX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36646177/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com