简体   繁体   English

在Power View中平均已过滤组的百分比

[英]Averaging percentages across filtered groups in Power View

I import data into Excel using Power Query, where I add a new column to calculate a usage percent. 我使用Power Query将数据导入Excel,在其中添加新列以计算使用百分比。 I then want to use Power View to visualize this data. 然后,我想使用Power View可视化此数据。 However, when applying filters on the data and wanting to view the average usage percent across filters, the results are incorrect as Power View is simply averaging the percentages, rather than calculating the totals of each parameter and applying the formula afterwards. 但是,在数据上应用过滤器并希望查看过滤器的平均使用百分比时,结果是不正确的,因为Power View只是对百分比进行平均,而不是计算每个参数的总和并随后应用公式。 Is there a way to write my formula, so the percentage will be calculated after filters are applied in Power View? 有没有办法写我的公式,因此在Power View中应用过滤器后将计算百分比?

In my example, Usage% = Direct/(Total-Fringe). 在我的示例中,Usage%= Direct /(Total-Fringe)。

Because the denominator is not constant, the usage percent for Group A is not simply an average of the Usage% cells assigned to Group A. The average of Usage% cells in group A is 75%, but the correct usage percent calculated for the Group A using parameter totals is 98/(168-40)= 76.56%. 因为分母不是恒定的,所以组A的使用百分比不仅仅是分配给组A的使用百分比单元的平均值。组A中的使用百分比单元的平均值是75%,而是为该组计算的正确使用百分比使用参数总计为98 /(168-40)= 76.56%。 Power View shows the incorrect 75%, as it is simply averaging the cells that correspond to Group A. Power View显示不正确的75%,因为它只是平均对应于A组的单元。

I would like to use the filters in Power View to view charts showing usage percent at various levels, including Group and Division, along with other information not shown in the example. 我想使用Power View中的过滤器查看图表,该图表显示了各个级别(包括组和分区)的使用百分比,以及示例中未显示的其他信息。

 ID Group   Division Direct Total   Fringe         Usage%
1   A       AA      40      40          0           1.00
2   A       AA      20      40          10          0.67
3   A       AB      18      40          15          0.72
4   A       AB      20      48          15          0.61
5   B       BA      40      40          0           1.00
6   B       BA      18      40          12          0.64
7   B       BB      12      40          20          0.60
8   B       BB      40      48          0           0.83

Create Usage % as a Measure in your Data Model, instead of as a column: 在数据模型中创建“ Usage %作为Measure ,而不是作为列:

Usage % = 
    DIVIDE (
        SUM ( MyTable[Direct] ),
        SUM ( MyTable[Total] ) - SUM ( MyTable[Fringe] ),
        BLANK()
    )

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

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