can you take absolute value of a column and then find the sum in power bi using DAX

3k Views Asked by At

I am new to power bi, and I have

enter image description here

I want to take the absolute value of the column, and then add it together, ie sum(abs(Column1)), but when I create a measure to do this, I get an error: enter image description here

yet, if I update the measure to abs(sum(Column1)), I get the value of 3, not 9.

Does anyone know a way around this issue

2

There are 2 best solutions below

0
On

Can create a measure like this

Measure = 
var _new_table = ADDCOLUMNS('table (2)', 
                            "new_col", abs('Table (2)'[Column1]))
return
CALCULATE(SUMX(_new_table, [new_col]))
0
On

Create this measure:

AbsoluteSum = 

VAR Positive = CALCULATE(SUM('table (2)'[Column1]), 'table (2)'[Column1] > 0) 
VAR Negative = CALCULATE(SUM('table (2)'[Column1]), 'table (2)'[Column1] < 0) * -1

RETURN
Positive + Negative