Search code examples
sqlsql-serverssasmdx

MDX query total sell price of rows with more than 10 quantity


I need to have a total sell price of rows that have more than 10 Quantity.

The result of the following query is the total sell price.

SELECT {[Sell Price]} ON COLUMNS
FROM SALES

I have to filter the above query with the condition ([Sell Quantity] > 10) for bellow dimensions.

[Customer].[Customer Name].[Customer Name]
[Goods].[Goods Name].[Goods Name]

Thanks in advance

EDIT Example data is like bellow

Customer       Goods       Quantity     Price
-------------------------------------------------
A              X            2            1000
B              X            15           2000
C              Y            20           3000
C              X            3            6000

Customers and Goods are dimensions. I need a total price of second and third rows because quantity of these rows is more than 10.

My expected result is 5000.


Solution

  • You need to use filter function. Based on the schema shared above your query will be

    Select 
    {
    [Sell Price]
    }on columns 
    from yourCube
    where 
    {filter(
        ([Customer].[Customer Name].[Customer Name],[Goods].[Goods Name].[Goods Name]),
        [Sell Quantity] > 10)}