Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Sum a column if another column has repeating values

Hello, I have a table that follows this structure: Code    Level    Total     111  A  1  111  A  1  222  B  1  333  B  2  333  B  1  111  C  1  222  D  1 ...
  • andhiii079845's avatar
    3 years ago

    Try this:

     

    MeasureTotal = 

    VAR __table = SUMMARIZE(Table2,Table2[Code],Table2[Level],"count",DISTINCTCOUNT(Table2[Code]),"sum",sum(Table2[Total]))
    VAR _table2 = SUMMARIZE(__table,Table2[Level],"countCode",sumx(__table,[count]),"sumtotal",sumx(__table,[sum]))
    RETURN IF(sumx(_table2,[countCode])>1,sumx(_table2,[sumtotal]),0)