Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Issues with CALCULATE (SUM)

Hi, I'm trying to get a columbn to SUM all the values for a given code, in every row that code is in. See below example

 

But the issue is my formula I'm using keeps giving just the SUM of the one row every time

 

Any help is much appreciated

 

Test = CALCULATE( SUM( Table[Value]), Table[Code] = Table[Code] )

 

CodeValueActual ResponseRequired Response
A226
A226
A226
B224
B224
C228
C228
C228
C228
D224
D224
  • Here are a couple of additional alternatives:

    Test =
    VAR _Code = Table[Code]
    RETURN
        CALCULATE ( SUM ( Table[Value] ), Table[Code] = _Code )

     

    Test =
    CALCULATE ( SUM ( Table[Value] ), ALLEXCEPT ( Table, Table[Code] ) )

4 Replies

  • Here are a couple of additional alternatives:

    Test =
    VAR _Code = Table[Code]
    RETURN
        CALCULATE ( SUM ( Table[Value] ), Table[Code] = _Code )

     

    Test =
    CALCULATE ( SUM ( Table[Value] ), ALLEXCEPT ( Table, Table[Code] ) )
  • DimaMD's avatar
    DimaMD
    Icon for Solution Sage rankSolution Sage

    hi Anonymous  If you use this in the count column, try this code

    CALCULATE(SUM('Лист1'[Value]),'Лист1'[Code] = EARLIER('Лист1'[Code]))

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    DimaMD thanks - that works for some, but a lot of the codes are adding up as they go, so onlt the last code in the table has the full total - Is there a better function that EARLIER() ??

    • Anonymous's avatar
      Anonymous
      Not applicable

      I got past this by adding another column that gives the MAX result. Ideally I'd like to avoid having 2 columns