SSRS 中的 MDX 参数
MDX Parameters in SSRS
大家好,希望有人能帮助我创建以下成员,这就是代码看起来如何硬编码。
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= 5100 AND [Measures].[Total Amount Bet] > 0 THEN "Casual"
WHEN [Measures].[Total Amount Bet] > 5100 AND [Measures].[Total Amount Bet] <= 25000 THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > 25000 THEN "Avid"
END MEMBER
现在我想传递数量范围,即 5100 和 25000 作为 SSRS 的参数,我已经尝试了以下方法,但没有成功。
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= STRTOSET(@FrequentMinValue,CONSTRAINED) AND [Measures].[Total Amount Bet] > 0 THEN "Casual"
WHEN [Measures].[Total Amount Bet] > STRTOSET(@FrequentMinValue,CONSTRAINED) AND [Measures].[Total Amount Bet] <= STRTOSET(@FrequentMaxValue,CONSTRAINED) THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > STRTOSET(@FrequentMaxValue,CONSTRAINED) THEN "Avid"
END MEMBER
如有任何建议,我们将不胜感激。
StrToSet 将字符串转换为集合。 Measures 是一个数值表达式,因此无法与集合进行比较。如果你去掉 StrToSet 会发生什么?
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= @FrequentMinValue AND [Measures].[Total Amount Bet] > 0 THEN "Casual"
WHEN [Measures].[Total Amount Bet] > @FrequentMinValue AND [Measures].[Total Amount Bet] <= @FrequentMaxValue THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > @FrequentMaxValue THEN "Avid"
END MEMBER
您可能需要在此处重新检查语法。最后的 MEMBER
看起来不属于这里。
CASE
的语法是
WITH MEMBER [Measures].x AS
CASE
WHEN 1>2 THEN 'false'
WHEN 2>1 THEN 'true'
ELSE 'none'
END
由于您从报告中提取值,因此该值将采用字符串格式。我不确定 MDX
引擎是否允许将数值与 string.So 进行比较是否更安全,您可能需要使用 StrToValue
函数将该文本值转换为数字。
您的最终查询应如下所示 -
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= STRTOVALUE(@FrequentMinValue,CONSTRAINED)
AND [Measures].[Total Amount Bet] > 0
THEN "Casual"
WHEN [Measures].[Total Amount Bet] > STRTOVALUE(@FrequentMinValue,CONSTRAINED)
AND [Measures].[Total Amount Bet] <= STRTOVALUE(@FrequentMaxValue,CONSTRAINED)
THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > STRTOVALUE(@FrequentMaxValue,CONSTRAINED)
THEN "Avid"
END
希望对你有帮助。
大家好,希望有人能帮助我创建以下成员,这就是代码看起来如何硬编码。
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= 5100 AND [Measures].[Total Amount Bet] > 0 THEN "Casual"
WHEN [Measures].[Total Amount Bet] > 5100 AND [Measures].[Total Amount Bet] <= 25000 THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > 25000 THEN "Avid"
END MEMBER
现在我想传递数量范围,即 5100 和 25000 作为 SSRS 的参数,我已经尝试了以下方法,但没有成功。
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= STRTOSET(@FrequentMinValue,CONSTRAINED) AND [Measures].[Total Amount Bet] > 0 THEN "Casual"
WHEN [Measures].[Total Amount Bet] > STRTOSET(@FrequentMinValue,CONSTRAINED) AND [Measures].[Total Amount Bet] <= STRTOSET(@FrequentMaxValue,CONSTRAINED) THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > STRTOSET(@FrequentMaxValue,CONSTRAINED) THEN "Avid"
END MEMBER
如有任何建议,我们将不胜感激。
StrToSet 将字符串转换为集合。 Measures 是一个数值表达式,因此无法与集合进行比较。如果你去掉 StrToSet 会发生什么?
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= @FrequentMinValue AND [Measures].[Total Amount Bet] > 0 THEN "Casual"
WHEN [Measures].[Total Amount Bet] > @FrequentMinValue AND [Measures].[Total Amount Bet] <= @FrequentMaxValue THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > @FrequentMaxValue THEN "Avid"
END MEMBER
您可能需要在此处重新检查语法。最后的 MEMBER
看起来不属于这里。
CASE
的语法是
WITH MEMBER [Measures].x AS
CASE
WHEN 1>2 THEN 'false'
WHEN 2>1 THEN 'true'
ELSE 'none'
END
由于您从报告中提取值,因此该值将采用字符串格式。我不确定 MDX
引擎是否允许将数值与 string.So 进行比较是否更安全,您可能需要使用 StrToValue
函数将该文本值转换为数字。
您的最终查询应如下所示 -
WITH MEMBER [Measures].[CoinInRank] AS CASE
WHEN [Measures].[Total Amount Bet] <= STRTOVALUE(@FrequentMinValue,CONSTRAINED)
AND [Measures].[Total Amount Bet] > 0
THEN "Casual"
WHEN [Measures].[Total Amount Bet] > STRTOVALUE(@FrequentMinValue,CONSTRAINED)
AND [Measures].[Total Amount Bet] <= STRTOVALUE(@FrequentMaxValue,CONSTRAINED)
THEN "Frequent"
WHEN [Measures].[Total Amount Bet] > STRTOVALUE(@FrequentMaxValue,CONSTRAINED)
THEN "Avid"
END
希望对你有帮助。