Forum Discussion

AleksandrG's avatar
AleksandrG
Helper I
3 years ago
Solved

DAX. Filtering the calculation through a parameter.

Guys, hello! Please help me to solve the following problem. I want to calculate the lost profit only for products whose profit is less than the specified value in the parameter. I created a meas...
  • AleksandrG's avatar
    AleksandrG
    3 years ago

    here is the solution 🙂

    VAR _table =
        FILTER (
            ADDCOLUMNS (
                Assortment4,
                "Persent", CALCULATE ( [% Profit], ALLSELECTED ( 'Calendar' ) ),
                "Profit"CALCULATE ( [Profit], ALLSELECTED ( 'Calendar' ) ),
                "SalesQty"CALCULATE ( [Sales Qty], ALLSELECTED ( 'Calendar' ) ),
                "SalesPerDay"CALCULATE ( [Sales Per Day], ALLSELECTED ( 'Calendar' ) )
            ),
            [Persent] > '% Profit'[Meaning % Profit]
        )
    RETURN
        SUMX (
            _table,
            IF (
                [Remainder] = 0,
                DIVIDE ( [Profit], [SalesQty], 0 ) * [SalesPerDay]
            )
        )