Forum Discussion

petercummins's avatar
petercummins
Frequent Visitor
9 years ago
Solved

summing values for last date by group

I need to be able to sum the total quantity of all transactions based on the last transaction date for each product category. So for a given product category "A" I need to get the last transaction d...
  • OwenAuger's avatar
    OwenAuger
    9 years ago

    petercummins

     

    A couple of options:

     

    =
    CALCULATE (
        SUM ( Transactions[Quantity] ),
        GENERATE (
            VALUES ( Transactions[Product Category] ),
            LASTDATE ( Transactions[Date] )
        )
    )
    =
    SUMX (
        VALUES ( Transactions[Product Category] ),
        CALCULATE ( SUM ( Transactions[Quantity] ), LASTDATE ( Transactions[Date] ) )
    )