开发者

MDX - Filter on measure value?

I want to write an MDX expression that uses a measure value in the WHERE statement.

For example: suppose I want to show the income from sold products in stores in different cities, but I only want to count the income for sold products that have a price over $10.

Thi开发者_运维百科s is what I tried but it doesn't work:

WHERE ([MEASURES].[Price]>10)

How can I do this using MDX?


If you have an access to olap db you can just create another metric Price (for example create expression for your fact table on DSV and create metric on this field) and use it for your further calculations. But if you don't have an access to db, you can try following script:

WITH
MEMBER [Measures].[Price10] AS
    'IIF([Measures].[Price] < 10,0,[Measures].[Price])'
MEMBER [Measures].[COST] AS
    '[Measures].[Price10]*[Measures].[Unit Count]'
SELECT
    {[Measures].[COST]} ON COLUMNS,
    {[Customer].[Customer Geography].[City].Members,[Customer].[Customer Geography].[All Customers]} ON ROWS
from [Adventure Works]

It's just a suggestion... and it depends on aggregation type which uses for calculating metric Price.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜