简体   繁体   English

Excel Pivot 表总平均值,总平均值包括 0

[英]Excel Pivot table Grand Average that includes 0's in total average

I have a custom Measure in my excel data model so I can calculate Grand Average in a pivot table ...我的excel 数据 model中有一个自定义度量,因此我可以在 pivot 表中计算总平均值...

MyMeasure:=VAR T1 =

SUMMARIZE(HC_Data,HC_Data[data date (Month)], "Total HC", [Count of NAME]) RETURN

IF(HASONEVALUE(HC_Data[data date (Month)]), SUM(HC_Data[HC count]), AVERAGEX( T1, [Total HC]))

now, at first sight, this works wonders, BUT.现在,乍一看,这创造了奇迹,但是。 it doesn't take into accounts months with 0's since the source data wouldn't have a record if there is a 0 in the pivot table.它不考虑带有 0 的月份,因为如果 pivot 表中有 0,源数据将没有记录。

The pivot table will show a 0 since the columns months are based on a full calendar, and pivot set to show 0 when there is no record. pivot 表将显示0 ,因为列月份基于完整日历,而 pivot 设置为在没有记录时显示0 so what i need is a way that the custom Measure accounts for 0's .. is this possible?所以我需要的是自定义量占0 的方式.. 这可能吗?

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Create a new table comprising a unique list of entries from the data date (Month) column and create a relationship between this new table and HC_Data .创建一个新表,其中包含来自数据日期(月)列的唯一条目列表,并在该新表和HC_Data之间创建关系。 You can then amend your measure to:然后,您可以将您的措施修改为:

MyMeasure:=VAR T1 =
    SUMMARIZE( Months, Months[Month], "Total HC",[Count of NAME] )
RETURN
    IF(
        HASONEVALUE( HC_Data[data date (Month)] ),
        SUM( HC_Data[HC count] ),
        AVERAGEX( T1, [Total HC] )
    )

I have assumed that the new table is called Months and comprises a single column called Month .我假设新表名为Months并且包含一个名为Month的列。

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

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