Power BI或Excel-如何基于数据透视表中的列添加自定义列

时间:2019-09-18 13:43:00

标签: excel powerbi pivot-table data-visualization powerbi-desktop

This is the sample of raw data. It shows the value that each of the property got on a scale of 1-10.

Pivot Table showing count of Value on scale for each property

我想在Excel中的数据透视表中创建自定义列,或者在Power Bi中创建矩阵。此列应基于数据透视表中的列,而不应基于表中已存在的列。

例如。我有一个表,其列标签从 1到10 ,并且有一个总计列。我创建了一个数据透视表来显示每列的计数。在此处的示例中,Mountain具有162个8值,197个9值和268个10值。我的问题是我想创建一个新的自定义列,它是这三个值的和按总数计算。在此示例中,它是(162 + 197 + 268)/ 829 = 76%

我无法做到。请帮帮我

1 个答案:

答案 0 :(得分:0)

在Power BI中,您正在寻找类似的措施。

SurveyCount := CountRows(MyTable)
CountAllValues := CALCULATE(SurveyCount,ALL(MyTable[Value On A Scale (1-10)]))
Count8Plus :=  CALCULATE(SurveyCount,MyTable[Value On A Scale (1-10)] >= 8)
Percentage8Plus := DIVIDE(Count8Plus , CountAllValues )

语法可能需要一些调整,但是这四个应该使您接近所需的内容。