gpt4 book ai didi

sql - 如何使用 MDX 查询获取最大值

转载 作者:行者123 更新时间:2023-12-05 04:16:30 25 4
gpt4 key购买 nike

我正在尝试获取维度表的最大值,其中数据与事实表相关

WITH 
MEMBER [Measures].[Max key] AS
Max
(
[DimAnchorDate].[Date Key].MEMBERS
,[DimAnchorDate].[Date Key].CurrentMember.Member_Key
)
SELECT
{
[Measures].[Max key]
} ON COLUMNS
FROM X;

这个查询给我输出:20141231在 FactTable 中,我们有直到 20141031 的数据。从上面的查询中,我想得到 20141031

enter image description here

所以现在我正在尝试从 DimAnchordate 表中获取最大值,就像它在 FactPatientDr 表中一样(即 20141031)。所以请建议我实现此目的的最佳方法...

最佳答案

我认为目前您正在查看立​​方体空间某些部分为空的日期 - 尝试使用 FactPatientDr 中的度量强制为 nonempty

WITH 
MEMBER [Measures].[Max key] AS
Max
(
nonempty(
[DimAnchorDate].[Date Key].MEMBERS
,[Measures].[SomeMeasureInFactPatientDr]
)
,[DimAnchorDate].[Date Key].CurrentMember.Member_Key
)
SELECT
{
[Measures].[Max key]
} ON COLUMNS
FROM X;

关于sql - 如何使用 MDX 查询获取最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27291090/

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