Passing multiple parameters into MDX query for WHERE clause
-
05-07-2019 - |
Question
If I have a simple MDX query such as:
SELECT
NON EMPTY { [Measures].[Amount] } ON COLUMNS,
NON EMPTY { [Date].[Date].[Date] }
ON ROWS FROM [MyCube]
And I want to filter it by an Id an another dimension this is easy enough.
SELECT
NON EMPTY { [Measures].[Amount] } ON COLUMNS,
NON EMPTY { [Date].[Date].[Date] }
ON ROWS FROM [MyCube]
WHERE (Asset].[Id].&[123])
but If I have multiple Id's is there any way to pass these in without dynamically building up the MDX query?
Solution
I'm not 100% sure about what you mean about not dynamically building up the MDX query, but the form of the query that you want is this:
SELECT
NON EMPTY { [Measures].[Amount] } ON COLUMNS,
NON EMPTY { [Date].[Date].[Date] } ON ROWS
FROM [MyCube]
WHERE (
[Asset].[Id].&[123],
[OtherDim].[Foo].&[3919]
)
...so I suppose that would need some dynamic building, but nothing too stressful.
OTHER TIPS
Try this:
SELECT
NON EMPTY { [Measures].[Amount] } ON COLUMNS,
NON EMPTY { [Date].[Date].[Date] } ON ROWS
FROM [MyCube]
WHERE (
{ [Asset].[Id].&[123],[Asset].[Id].&[124]}
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow