maven
maven

Reputation: 35

DAX | Sum up rows for a column based on conditions in another column

I am new to DAX, I have a data which looks like -

col1 col2
A 20
A 10
B 30
B 20

My output should be -

col1 col2 col3
A 20 30
A 10 30
B 30 50
B 20 50

I have tried writing a measure but it dosnt work -

col3 =
CALCULATE (
    SUM ( Sheet1[col2] ),
    FILTER (
        ALLSELECTED ( Sheet1 ),
        Sheet1[col1] == Sheet1[col1]
    )
)

Upvotes: 0

Views: 116

Answers (1)

Peter
Peter

Reputation: 12295

If you are actually looking for a formula to calculate col3, take this one here and put all cols into a table visual.

col3 = 
CALCULATE(
    SUM('Sheet1'[col2]),
    ALLEXCEPT(
        'Sheet1',
        'Sheet1'[col1]
    )
)

enter image description here

Upvotes: 2

Related Questions