Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

SUM - Only when a specific number is reached

Hi guys,

 

quick question:

 

CustomerNumber of PurchaseAmountYear
A45002019
A34002019
B22002019
C21002019
A22002019
B13002019
C12002019
A11002019
B41002018
B31002018
B21002018
B11002018
C23002018
C13002018
A12002018


I want to calculate the sum for each customer who has more than 3 purchases per year. Each year the counter starts at 0 again.

 

In 2018: Customer B has made more than 3 purchases , the sum is  400.


In 2019: Customer A has made more than 3 purchases, the sum is 1200.

 

All other customers have less than 3 purchases in the correspoding year and are therefore not consindered in the calculation.

 

Any ideas ? I need some kind of a Serach function as I suppose but this is only available for text columns.

  • Hello Alex

     

    try this measure:

     

    =
    SUMX(
        VALUES( Data[Year] ),
        CALCULATE(
             SUM( Data[Amount] ),
             FILTER(
                 VALUES( Data[Customer] ),
                  CALCULATE( COUNTROWS( Data ) ) > 3
            )
        )
    )

3 Replies

  • Hello Alex

     

    try this measure:

     

    =
    SUMX(
        VALUES( Data[Year] ),
        CALCULATE(
             SUM( Data[Amount] ),
             FILTER(
                 VALUES( Data[Customer] ),
                  CALCULATE( COUNTROWS( Data ) ) > 3
            )
        )
    )
  • jtownsend21's avatar
    jtownsend21
    Icon for Responsive Resident rankResponsive Resident

    Try this

     

    Sum - Over 3 Purchases = 
    CALCULATE(
        SUM('Table 1'[Amount]),
        FILTER(Table 1,
            DISTINCTCOUNT('Table 1'[Number of Purchase]) > 3
        )
    )
  • Anonymous's avatar
    Anonymous
    Not applicable

    Sorry for the delay reply - both answers worked, thanks.