Is there a way to use an MDX Case Statement without the break functionality? In the example below, I want for [Measures].[Count] = 7 to show both "MEDIUM" AND" LARGE" (or just "LARGE" if it's possible) not only "MEDIUM".
CASE
WHEN [Measures].[Count] > 4 THEN 'MEDIUM'
WHEN [Measures].[Count] > 6 THEN 'LARGE'
WHEN [Measures].[Count] > 3 THEN 'SMALL'
ELSE "NONE"
END
First of all, you should reorder you WHEN
clauses, as in MDX (like in SQL), the first clause that matches wins:
CASE
WHEN [Measures].[Count] > 6 THEN 'LARGE'
WHEN [Measures].[Count] > 4 THEN 'MEDIUM'
WHEN [Measures].[Count] > 3 THEN 'SMALL'
ELSE "NONE"
END
would return 'LARGE' for 7.
You cannot return more than one value from a CASE
expression. CASE
is an expression (even if the MS documentation wrongly calls it statement in some places). And an expression can have only one result.
Imagine you write an Excel formula (which is also an expression). You have only one cell to display the result, so the formula can only deliver one result.
But of course, the result could be a combination of several results, like a string concatenation. Or in the case of the CASE
expression, you could return sets which can have one or more members. But even then you would need different WHEN
branches, each just returning one set.
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.