简体   繁体   English

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

[英]power BI or Excel - How to add a custom column based on columns in the pivot table

This is the sample of raw data. 这是原始数据的样本。 It shows the value that each of the property got on a scale of 1-10. 它显示每个属性的值在1-10的范围内。

Pivot Table showing count of Value on scale for each property 数据透视表显示每个属性的规模价值计数

I want to create a custom column in a pivot table in excel or a matrix in power Bi. 我想在Excel中的数据透视表中或Power Bi中的矩阵中创建自定义列。 This column should be based on the columns in the pivot table and not on the already existing columns in the table. 此列应基于数据透视表中的列,而不应基于表中已存在的列。

Eg. 例如。 I have a table with column labels from 1 to 10 and a Total column. 我有一张表,其列标签的范围是1到10,并且有Total列。 I created a pivot table to show the count of each of these columns. 我创建了一个数据透视表来显示每列的计数。 In the example here, Mountain has 162 values of 8, 197 values of 9 and 268 values of 10. My question is I want to create a new custom column which is the sum of just these three values divided by the total count. 在这里的示例中,Mountain具有162个8值,197个9值和268个10值。我的问题是我想创建一个新的自定义列 ,该是这三个值的总和除以总数。 In this example , it is(162+197+268)/829 = 76% 在此示例中,它是(162 + 197 + 268)/ 829 = 76%

I am not able to do it. 我做不到。 Please help me out 请帮帮我

In Power BI you're looking at measures something like this. 在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 )

The syntax might need a little tweak but these four should get you close to what you need. 语法可能需要一些调整,但是这四个应该使您接近所需的内容。

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

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