在DAX中按类型汇总一列中的值

时间:2020-08-25 22:02:30

标签: powerbi dax

我有一张桌子

Table1

我要总结每种类型的值并创建其他两个度量/列(百分比和累积百分比),如下表所示 Table2

我尝试了以下DAX

column = summarize(Table1, Table1[Type], "Total Value", sum(Table1[value]))

但是出现以下错误。我也尝试使用GroupBy函数,但遇到相同的错误。 The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

请帮助!

1 个答案:

答案 0 :(得分:1)

原始数据和最终输出 enter image description here

目标数据的详细信息:
对于“值”列,选择聚合作为总和

enter image description here

“%GT值”列(在您的情况下为百分比列)。在表格视觉效果中再次拉出值列,然后选择“将值显示为”,然后选择“总计百分比” enter image description here

对于累积百分比,请创建运行总计的快速度量并将其再次显示为“总计百分比”

enter image description here