简体   繁体   English

你能取一列的绝对值,然后使用 DAX 在 power bi 中求和吗

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

I am new to power bi, and I have我是 power bi 的新手,我有

在此处输入图像描述

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:我想取列的绝对值,然后将它们相加,即sum(abs(Column1)) ,但是当我创建一个度量来执行此操作时,出现错误: 在此处输入图像描述

yet, if I update the measure to abs(sum(Column1)) , I get the value of 3 , not 9 .但是,如果我将度量更新为abs(sum(Column1)) ,我得到的值是3而不是9

Does anyone know a way around this issue有谁知道解决这个问题的方法

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]))

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM