Return 来自 MDX 查询 SSAS 的两个日期之间的数据
Return data between two dates from a MDX Query SSAS
我正在尝试过滤两个日期范围之间的数据。它的数据类型是datetime
。
我已经通过 SSAS 中的查询设计器生成了查询。
下面是我的数据集示例:
度量组和维度的示例图像:
我使用的示例过滤器:
生成的 MDX 查询:
`SELECT NON EMPTY { [Measures].[Status] } ON COLUMNS, NON EMPTY { ([Lobby].[Added Local Time].[Added Local Time].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Lobby].[Added Local Time].&[2020-01-02T10:32:37.806667] : [Lobby].[Added Local Time].&[2020-02-19T13:43:13.833333] ) ON COLUMNS FROM ( SELECT ( { [Lobby].[Status].[All] } ) ON COLUMNS FROM [LTS KROI DEMO])) WHERE ( [Lobby].[Status].[All] ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS`
问题:
问题是它不会根据给定的 datetime
范围过滤数据。两者都没有给出任何错误。
如果我只使用 Filter - Status 一个特定的值而不给出所有它一切正常。
请尝试过滤功能。它会更慢但应该有效,因为您采用的方法仅在确切的日期时间存在时才有效
SELECT { [Measures].[Status] } ON COLUMNS, NON EMPTY {
Filter(
[Lobby].[Added Local Time].[Added Local Time].ALLMEMBERS,
[Lobby].[Added Local Time].CurrentMember.MemberValue >= CDate("2020-01-02 10:32:37.806667")
and [Lobby].[Added Local Time].CurrentMember.MemberValue <= CDate("2020-02-19 13:43:13.833333")
)
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS
FROM [LTS KROI DEMO]
CELL PROPERTIES VALUE
I was able get the desired result by following the answer of
@GregGalloway by making a small change to the parameter I passed as
the date. When I removed time passing the date to the Cdate
function
it work fine.
SELECT { [Measures].[Status] } ON COLUMNS, NON EMPTY {
Filter(
[Lobby].[Added Local Time].[Added Local Time].ALLMEMBERS,
[Lobby].[Added Local Time].CurrentMember.MemberValue >= CDate("2020-01-02")
and [Lobby].[Added Local Time].CurrentMember.MemberValue <= CDate("2020-02-19")
)
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS
FROM [LTS KROI DEMO]
CELL PROPERTIES VALUE
我正在尝试过滤两个日期范围之间的数据。它的数据类型是datetime
。
我已经通过 SSAS 中的查询设计器生成了查询。
下面是我的数据集示例:
度量组和维度的示例图像:
我使用的示例过滤器:
生成的 MDX 查询:
`SELECT NON EMPTY { [Measures].[Status] } ON COLUMNS, NON EMPTY { ([Lobby].[Added Local Time].[Added Local Time].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Lobby].[Added Local Time].&[2020-01-02T10:32:37.806667] : [Lobby].[Added Local Time].&[2020-02-19T13:43:13.833333] ) ON COLUMNS FROM ( SELECT ( { [Lobby].[Status].[All] } ) ON COLUMNS FROM [LTS KROI DEMO])) WHERE ( [Lobby].[Status].[All] ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS`
问题:
问题是它不会根据给定的 datetime
范围过滤数据。两者都没有给出任何错误。
如果我只使用 Filter - Status 一个特定的值而不给出所有它一切正常。
请尝试过滤功能。它会更慢但应该有效,因为您采用的方法仅在确切的日期时间存在时才有效
SELECT { [Measures].[Status] } ON COLUMNS, NON EMPTY {
Filter(
[Lobby].[Added Local Time].[Added Local Time].ALLMEMBERS,
[Lobby].[Added Local Time].CurrentMember.MemberValue >= CDate("2020-01-02 10:32:37.806667")
and [Lobby].[Added Local Time].CurrentMember.MemberValue <= CDate("2020-02-19 13:43:13.833333")
)
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS
FROM [LTS KROI DEMO]
CELL PROPERTIES VALUE
I was able get the desired result by following the answer of @GregGalloway by making a small change to the parameter I passed as the date. When I removed time passing the date to the
Cdate
function it work fine.
SELECT { [Measures].[Status] } ON COLUMNS, NON EMPTY {
Filter(
[Lobby].[Added Local Time].[Added Local Time].ALLMEMBERS,
[Lobby].[Added Local Time].CurrentMember.MemberValue >= CDate("2020-01-02")
and [Lobby].[Added Local Time].CurrentMember.MemberValue <= CDate("2020-02-19")
)
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS
FROM [LTS KROI DEMO]
CELL PROPERTIES VALUE