Forum Discussion

Sperling's avatar
Sperling
Advocate II
3 years ago
Solved

Measure help

Hi,   I'm having issues with an out of stock measure.   Currently I have an qty. available to sell measure that is made up of two other measures. One is an qty. in stock measure - shows how much...
  • Sperling's avatar
    Sperling
    3 years ago

    In trying to debug it by splitting it more up, it turned out to work.
    Never tried a measure not working by using VAR.

    So in my solution I just divided the DAX presented into 2 individual measures:

    Out of Stock status =
    VAR QtyAtS =
        SUMX(
            DISTINCT(DimItem[Item Number]),
            [Quantity available to Sell]
        )

    RETURN
        IF(
            CALCULATE(
                QtyAtS
            ) <= 0,
            1,
            0
        )

    Out of Stock count =
        COUNTROWS(
            FILTER(
                DISTINCT(
                    DimItem[Item Number]
                ),
                [Out of Stock status] = 1
            )
        )


    I then divided the Out of Stock count measure with a distinct count of Item Numbers and it works - a bit confused but at least it works.