2017-03-04 13 views
0

私はクエリを持っていますが、where句とサブクラスでパラメトリックに日付になりたいです。 どうすればいいですか? 私はwith句で定義したとき、私はwhere句とサブクエリでそれを使うことができません。MDX where句とサブクエリに日付パラメータを渡すにはどうすればいいですか

私のメインのクエリは次のとおりです。

WITH 
SET [countOfProple] As 
    filter ([VW Dim Customer Broker Branch].[Customer BK].[Customer BK],[Measures].[Trade Cnt]>0) 

    member [measures].[numbers] AS 
    count([countOfProple]) 

select 
[measures].[numbers] on 0 

    from (
      select 

      {[VW Dim Customer Broker Branch].[Customer BK].[Customer BK]*[VW Dim Customer Broker Branch].[Reception Date].&[2006-09-23T00:00:00]:[VW Dim Customer Broker Branch].[Reception Date].&[2009-08-30T00:00:00]} on 0 
      from [DV Present] 
     ) 
    where [Vw Dim Date].[Gregorian Date].&[2006-09-23T00:00:00]:[Vw Dim Date].[Gregorian Date].&[2009-08-30T00:00:00]; 

私は以下のからそれを変更した場合、それはエラーがあります:

WITH 
SET [countOfProple] As 
    filter ([VW Dim Customer Broker Branch].[Customer BK].[Customer BK],[Measures].[Trade Cnt]>0) 

SET Date1 AS 
[VW Dim Customer Broker Branch].[Reception Date].&[2006-09-23T00:00:00]:[VW Dim Customer Broker Branch].[Reception Date].&[2009-08-16T00:00:00] 

SET Date2 AS 
[Vw Dim Date].[Gregorian Date].&[2006-09-23T00:00:00]:[Vw Dim Date].[Gregorian Date].&[2009-08-16T00:00:00]; 

    member [measures].[numbers] AS 
    count([countOfProple]) 

select 
[measures].[numbers] on 0 

    from (

      select 

      {[VW Dim Customer Broker Branch].[Customer BK].[Customer BK]*Date1} on 0 
      from [DV Present] 
     ) 
    where Date2 

答えて

0

私は「日付2」は、あなたのパラメータであると仮定します。あなたは、これらの機能のいずれかを使用する必要があります

そして、これらの関数のいずれかの内側に、あなたは、フルを表す文字列を構築する必要がありますメンバーまたはセットの名前(amersandを含む)。

文字列で、我々のハードコードは、それが次のいずれかのようなルックスする場合:メンバーパラメータについては

:設定パラメータについては

WHERE 
    StrToMember('[Vw Dim Date].[Gregorian Date].&[2009-08-30T00:00:00]') 

WHERE 
    StrToMember('[Vw Dim Date].[Gregorian Date].&[2006-09-23T00:00:00]:[Vw Dim Date].[Gregorian Date].&[2009-08-30T00:00:00]') 

の場合ssrsと私たちは2つの終了日の値 "2009年8月30日"または "2010年8月30日"のいずれかを取ることができるパラメータ@DtStringを持っているとしたら、設定されたバージョンを以下のように動的にすることができます:

WHERE 
    StrToMember('[Vw Dim Date].[Gregorian Date].&[2006-09-23T00:00:00]:[Vw Dim Date].[Gregorian Date].&[' + @DtString + 'T00:00:00]') 
関連する問題