我正在尝试使用计算成员构建带参数的查询。
我已经创建了“硬编码”的司法计数的计算成员,而我创建的参数不会影响每个组的总数。
但是,我需要使用工作参数列出每个总计数。如果所选司法类型没有值,则应显示零计数。
我确信有一种简单的方法,但对于MDX / SSRS来说还是相当新的。非常感谢任何帮助!
以下是查询:
WITH
Member [Measures].[Jud] as
(
[Dim Foreclosure Loan].[Judicial Flag].[1],
[Dim Foreclosure Loan].[FCL Stage].&[Sale Held],
[Measures].[Loan Count]
)
Member [Measures].[Non-Jud] as
(
[Dim Foreclosure Loan].[Judicial Flag].[0],
[Dim Foreclosure Loan].[FCL Stage].&[Sale Held],
[Measures].[Loan Count]
)
Member [Measures].[Total] as
(
[Dim Foreclosure Loan].[Judicial Flag],
[Dim Foreclosure Loan].[FCL Stage].&[Sale Held],
[Measures].[Loan Count]
)
-------------------------------- Query Begins --------------------------------
SELECT NON EMPTY
{
([Dim Date].[Calendar].[Day].Members)
} ON ROWS,
NON EMPTY
({
([Measures].[Jud]),
([Measures].[Non-Jud]),
([Measures].[Total])
}) ON COLUMNS
FROM ( SELECT ( STRTOSET(@DimForeclosureLoanJudicialFlag, CONSTRAINED) ) ON COLUMNS
FROM [Foreclosure])
WHERE
(IIF( STRTOSET(@DimForeclosureLoanJudicialFlag, CONSTRAINED).Count = 1,
STRTOSET(@DimForeclosureLoanJudicialFlag, CONSTRAINED),
[Dim Foreclosure Loan].[Judicial Flag].currentmember)
)CELL PROPERTIES VALUE
更新:需要帮助提供的iif语句;见下面的评论。
答案 0 :(得分:0)
我并不是100%清楚你要问的是什么,但如果我要重申,我认为这是你正在尝试做的事情。我想你想在专栏上看到Jud,Non-Jud和Total。我认为您正在尝试使用该参数来选择特定的司法标志。什么不清楚的是参数值是否限制为1和2,如你所示的措施,或者是否存在有1和2的子项的层次结构。我将假设第一个,因为它最容易解释,我们可以从那里去。
您需要为司法标志1和2设置措施,以考虑WHERE
条款中的内容。现在它们是硬编码的,它告诉SSAS忽略WHERE
子句中的任何内容。您需要通过在度量定义中包含IIF
语句来有条件地使用它。您应该返回NULL
值作为False条件,以便SSAS可以最佳地执行查询,然后使用format_string属性填充零代替NULL
(这比使用0更好)在表现错误的情况下)。但是,列上的NON EMPTY
关键字将消除WHERE
子句中未包含的司法标记,因此您需要将其删除。将其保留在行上,以便仅显示具有Jud或Non-Jud值的日期。
根据我对您尝试做的事情的猜测,我们尝试了您的查询:
WITH
MEMBER [Measures].[Jud] AS
iif(
[Dim Foreclosure Loan].[Judicial Flag].CurrentMember is
[Dim Foreclosure Loan].[Judicial Flag].[1],
(
[Dim Foreclosure Loan].[Judicial Flag].[1]
,[Dim Foreclosure Loan].[FCL Stage].&[Sale Held]
,[Measures].[Loan Count]
),
NULL), format_string="#;#;0;0"
MEMBER [Measures].[Non-Jud] AS
iif(
[Dim Foreclosure Loan].[Judicial Flag].CurrentMember is
[Dim Foreclosure Loan].[Judicial Flag].[0],
(
[Dim Foreclosure Loan].[Judicial Flag].[0]
,[Dim Foreclosure Loan].[FCL Stage].&[Sale Held]
,[Measures].[Loan Count]
),
NULL), format_string="#;#;0;0"
MEMBER [Measures].[Total] AS
(
[Dim Foreclosure Loan].[Judicial Flag]
,[Dim Foreclosure Loan].[FCL Stage].&[Sale Held]
,[Measures].[Loan Count]
)
SELECT
NON EMPTY
{
[Dim Date].[Calendar].[Day].MEMBERS
} ON ROWS
,
{
[Measures].[Jud]
,[Measures].[Non-Jud]
,[Measures].[Total]
} ON COLUMNS
FROM
(
SELECT
StrToSet
(@DimForeclosureLoanJudicialFlag
,CONSTRAINED
) ON COLUMNS
FROM [Foreclosure]
)
WHERE
IIF
(
StrToSet
(@DimForeclosureLoanJudicialFlag
,CONSTRAINED
).Count
= 1
,StrToSet
(@DimForeclosureLoanJudicialFlag
,CONSTRAINED
)
,[Dim Foreclosure Loan].[Judicial Flag].CurrentMember
)
CELL PROPERTIES VALUE, FORMATTED_VALUE;