gpt4 book ai didi

ssas - 对 Select 语句的特定列求和

转载 作者:行者123 更新时间:2023-12-04 20:10:37 26 4
gpt4 key购买 nike

我对 SSAS 和 MDX 非常陌生,并试图了解它的概念。我需要帮助。

我有一个预订事实表,我想按市场获取特定预订年份和出发年份的乘客数量,并且对于每个出发年份,我想要一个总列。但无法弄清楚如何将这些列聚合为一。

这是我现在的代码:

SELECT  {
(CROSSJOIN([Dep Date].[Calendar Year].&[2012],[Book Date].[Calendar Year].&[2011] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2012],[Book Date].[Calendar Year].&[2012] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2013],[Book Date].[Calendar Year].&[2012] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2013],[Book Date].[Calendar Year].&[2013] ))
}
ON 0,
NON EMPTY [Fact Lead Pax Report].[Mc Major].MEMBERS
ON 1
FROM [Lead Pax Report]
WHERE { [Fact Lead Pax Report].[Res Status].&[A] }

这是我的结果表,我想添加黄色标记所在的总列:

http://i.stack.imgur.com/5SNAk.png

最佳答案

添加另一列来计算特定年份的所有离开怎么样?

例如:

WITH SET [ESC TOURS BY MARKET] AS 
Filter(
[Fact Lead Pax Report].[Mc Major].[Mc Major],
([Fact Lead Pax Report].[Mc Major].currentMember.name <> 'AIR') AND ([Fact Lead Pax Report].[Mc Major].currentMember.name <> 'DEFAULT')
)
SELECT {
(CROSSJOIN([Dep Date].[Calendar Year].&[2012],[Book Date].[Calendar Year].&[2011] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2012],[Book Date].[Calendar Year].&[2012] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2012],[Book Date].[Calendar Year] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2013],[Book Date].[Calendar Year].&[2012] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2013],[Book Date].[Calendar Year].&[2013] )),
(CROSSJOIN([Dep Date].[Calendar Year].&[2013],[Book Date].[Calendar Year] ))
}
ON 0,
[ESC TOURS BY MARKET]
ON 1
FROM [Lead Pax Report]
WHERE { [Fact Lead Pax Report].[Res Status].&[A] }

关于ssas - 对 Select 语句的特定列求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17725043/

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