3

I created a report against the demo Sales cube. It includes a date picker with range (from & to) where the "on selection" event is named date window.
& a pivot table with a MDX query similar to this:

SELECT 
        [Time].[Calendar].[Day].[7 Jan 2005]
      : 
        [Time].[Calendar].[Day].[10 Jan 2005] ON 0
FROM [Sales];  

I would like to replace the fixed dates in the query by the from and to in the date picker. How to do that?

4

3 回答 3

2

In many dialects of mdx if you have a parameter called @aDate and let us assume its current value is 7 Jan 2005 then you can add to mdx via the strToMember function like this:

strToMember('[Time].[Calendar].[Day].[' + @aDate + ']')

Or the strToSet function like this:

strToSet('[Time].[Calendar].[Day].[' + @aDate + ']:[Time].[Calendar].[Day].[' + @aSECONDDate + ']')
于 2017-04-19T11:25:46.743 回答
2

In icCube I'd rather use MDX function LookupByKey instead of strToMember. Besides the better typing the compiler can easily guess the hierarchy that is handy in a few scenarios. IMHO, try never using StrToMember. Something like :

 [Calendar].[Day].lookupByKey( StringToDate(@date,"d/M/yyyy") )

To parse strings into dates you've a few functions available ( here and here ).

I think the range filter directly returns the MDX range expression in the event directly (contact us directly if it's not the case).

于 2017-04-19T12:06:39.667 回答
1

As it is mentioned above, IcCube Date Picker widget returns valid MDX value for range. Here is demo report with described configuration.

For more details check Date Picker's settings and Pivot Table's mdx settings.

于 2017-04-19T13:57:06.600 回答