SSRS中的MDX参数

时间:2015-05-20 07:35:10

标签: reporting-services ssas mdx ssrs-2008-r2

美好的一天,希望有人可以协助我有我正在创建的以下成员,这就是代码看起来如何工作的硬编码。

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 

非常感谢任何建议。

2 个答案:

答案 0 :(得分:1)

StrToSet将字符串转换为集合。度量是一个数值表达式,因此与集合进行比较将不起作用。如果你摆脱了StrToSet会发生什么?

Universal 8.1 App

答案 1 :(得分:0)

您可能需要在此处重新检查语法。最后的MEMBER看起来不像是属于这里。

CASE的语法是

WITH MEMBER [Measures].x AS 
CASE 
   WHEN 1>2 THEN 'false'
   WHEN 2>1 THEN 'true'
   ELSE 'none'
END

由于您从report中提取值,因此该值将采用字符串格式。我不确定MDX引擎是否允许将数值与字符串进行比较。因此,为了更安全,您可能需要使用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

希望它对你有所帮助。