Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX Calculate with Filter

Hi there,    I have a sales data table as below. Each customer has more than 1 contract.   I want to calculate the total sales between the latest contract date for each customer and up to 31 Dec ...
  • smpa01's avatar
    4 years ago

    Anonymous  can you try this

    Measure =
    CALCULATE (
        [Total Sales],
        FILTER (
            Sales,
            Sales[Contract Date]
                >= CALCULATE ( MAX ( Sales[Contract Date] ), ALLEXCEPT ( Sales, Sales[Customer] ) )
                && Sales[Contract Date] <= DATE ( 2021, 12, 31 )
        )
    )
    

     

     

  • smpa01's avatar
    smpa01
    4 years ago

    Anonymous  try this

    Measure =
    SUMX (
        VALUES ( 'Table'[Customer] ),
        CALCULATE (
            MAX ( 'Table'[Car Purchased] ),
            ALLEXCEPT ( 'Table', 'Table'[Customer] )
        )
    )