简体   繁体   中英

MDX Query with two or more date ranges

Is it possible to put two or more data ranges in MDX Query?

This part of mdx query:

FILTER([Time].[Date].MEMBERS,[Time].CURRENTMEMBER IN([Time].[2013].[2].[2013-02-01] : [Time].[2014].[7].[2014-07-07]))

converted to SQL is:

WHERE Date BETWEEN '2013-02-01' AND '2014-07-07'

What I want to achieve in MDX:

SQL:

WHERE (Date BETWEEN '2013-02-01' AND '2014-07-07') OR (Date Between '2012-07-06' AND '2012-08-17');

The ":" operator just creates a naturally ordered Set of all Members between the two Members (inclusive).

You can use Set notation to create a set containing the elements of other Sets as long as they are in the same Hierarchy.

FILTER([Time].[Date].MEMBERS,[Time].CURRENTMEMBER IN(
    { 
        [Time].[2013].[2].[2013-02-01] : [Time].[2014].[7].[2014-07-07], 
        [Time].[2012].[7].[2012-07-06] : [Time].[2012].[8].[2012-08-17]
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM