I have a cube which contains many-to-many relationships between products (say T-Shirts) and their attributes (e.g. color, size, etc.).
The many-to-many dimension has been designed as it was described here: https://docs.microsoft.com/en-us/sql/analysis-services/lesson-5-3-defining-a-many-to-many-relationship
Now, I would like to write MDX query which contains some AND/OR filtering. Basically I need to get the quantity of all t-shirts that meet BOTH requirements:
- Size is M or L,
- Color is red.
In other words, I would like to exclue all green M-sized, red S-sized, etc.
We should use "AND" logic when checking the attributes and "OR" logic when checking the values of each attribute.
I created something as below, but it doesn't seem to work properly:
SELECT {
[Geography].[City]
} ON ROWS,
{
[Measures].[Quantity]
} ON COLUMNS
FROM [My cube]
WHERE (
(
[Attributes].[Attribute].&[Size] *
{
[Attributes].[AttributeValues].&[M]
, [Attributes].[AttributeValues].&[L]
}
),
(
[Attributes].[Attribute].&[Color] *
{
[Attributes].[AttributeValues].&[Red]
}
)
)