Forum Discussion

afaque03's avatar
afaque03
Helper I
9 years ago
Solved

Calculate On Hand quantity

Hello Freinds,   I have a matrix table where im showing month wise incoming and outgoing quantity and there is a filter of month. I want to calculate On-Hand quantity for the selected month. My rep...
  • v-ljerr-msft's avatar
    v-ljerr-msft
    9 years ago

    Hi afaque03,

     

    My mistake.

     

    Could you try the formula below to see if it works? :smileyhappy:

    On-Hand Quantity =
    VAR currentYearMonth =
        MAX ( 'Table1'[YearMonth] )
    VAR productName =
        FIRSTNONBLANK ( 'Table1'[Product Name], 1 )
    RETURN
        CALCULATE (
            SUM ( 'Table1'[Incoming Quantity] ) - SUM ( 'Table1'[Outgoing Quantity] ),
            FILTER (
                ALL ( Table1 ),
                'Table1'[YearMonth]
                    <= currentYearMonth - 1
                    && 'Table1'[Product Name] = productName
            )
        )
    

     

    Regards