How can I write an mdx query that slices by both a date range and dimension member value

风格不统一 提交于 2019-12-12 18:01:38

问题


I need to write an mdx query that limits its results by the value of a dimension but also by a date range. I know how to do one or the other but I can't figure out how to do both at once.

This works for the date range:

SELECT {[Measures].[Hours]} ON COLUMNS, [Time Type].[Type].Members ON ROWS 
FROM [cube]
WHERE {[Date].[Date ISO].[2013-01-26]:[Date].[Date ISO].[2013-06-25]}

And this works for the member slicer:

SELECT {[Measures].[Hours]} ON COLUMNS, [Time Type].[Type].Members ON ROWS 
FROM [cube]
WHERE [Time Type].[Allocation Type].[Direct]

How do I constrain the results by both of these WHERE clause values at the same time? I've tried putting them both in the same WHERE like so:

SELECT {[Measures].[Hours]} ON COLUMNS, [Time Type].[Type].Members ON ROWS 
FROM [cube]
WHERE ([Time Type].[Allocation Type].[Direct],
    {[Date].[Date ISO].[2013-01-26]:[Date].[Date ISO].[2013-06-25]})

but Mondrian replies with: No function matches signature (, ).

Note that Mondrian does not support subqueries or I would do it that way.

I think I might need to use a filter function on my rows for my member constraint but I need to filter on something that I don't want to display, which I am not sure how to do.


回答1:


I think crossjoin is the answer like so:

SELECT {[Measures].[Hours]} ON COLUMNS, [Time Type].[Type].Members ON ROWS 
FROM [cube]
WHERE CROSSJOIN([Time Type].[Allocation Type].[Direct],
    {[Date].[Date ISO].[2013-01-26]:[Date].[Date ISO].[2013-06-25]})

CROSSJOIN creates all the combinations of the 'Direct" member and the dates in my range as tuples for my WHERE slicer. I think this is the right answer.



来源:https://stackoverflow.com/questions/17310762/how-can-i-write-an-mdx-query-that-slices-by-both-a-date-range-and-dimension-memb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!