简体   繁体   English

计算动力枢轴模型中总数的百分比

[英]Calculating Percent of Total in Power Pivot Model

I have created a power pivot table as shown in the picture. 我已经创建了一个电源数据透视表,如图所示。 I want to calculate quarter over quarter sales change. 我想计算一个季度的销售额变化。 For which I have to divide for example corporate family "Acer" 's sales in 2012Q4 by sum of all the corporate family. 为此,我必须将所有企业家族的总和除以企业家族"Acer"2012Q4的销售额。 I am using calculated measure to do this, but I am not sure what formula I can use. 我使用计算的测量来做到这一点,但我不确定我可以使用什么公式。

在此输入图像描述

My need is to create two columns, one for 2012Q4 percent of total and one for 2013Q1 percent of total. 我需要创建两个列,一个用于2012Q4的总数,一个用于2013Q1的总数。 Then I will create another measure to find the difference. 然后我将创建另一个措施来找到差异。 So the formula for 2012Q4 should be like this 1624442 / (1624442+22449+1200+16123) . 所以2012Q4的公式应该是1624442 / (1624442+22449+1200+16123) Any idea which function can help me do it? 知道哪个功能可以帮我做到这一点?

It sounds like you are measuring the change in the percent of total for each corporate family from quarter to quarter. 听起来你正在衡量每个企业家庭每季度总收入百分比的变化。 You will need to create 3 calculated measures. 您需要创建3个计算的度量。 I'm not sure what your model looks like so I can't give you the exact formula, but here is the idea. 我不确定你的模型是什么样的,所以我不能给你确切的公式,但这是想法。

CurrentQtr%ofTotal:= Divide(Sum('Sales'[Units]),Calculate(Sum('Sales'[Units]), All['Product'[Corporate Family])))

PrevQtr%ofTotal:= DIVIDE(CALCULATE(Sum('Sales'[Units]), DATEADD(DimDate[DateKey], -1, QUARTER)),
CALCULATE(Sum('Sales'[Units]), DATEADD(DimDate[DateKey], -1, QUARTER), All('Product'[Corporate Family]))))

Change%ofTotal:= DIVIDE(([CurrentQtr%ofTotal]-[PrevQtr%ofTotal]),[PrevQtr%ofTotal])

I used the divide function because it handles divide by zero errors. 我使用除法函数,因为它处理除零错误。 You use the ALL function to remove the filter on the Corporate Family column from the filter context. 您可以使用ALL函数从过滤器上下文中删除Corporate Family列上的过滤器。 The Change%ofTotal is just to find the differenc. Change%ofTotal只是为了找到差异。 I'm calculating % change but you may just want to subtract. 我正在计算%变化,但您可能只想减去。

Here's the link to a good blog post on time intelligence. 这是关于时间智能的好博客文章的链接 And here's one on calculating percent of total. 这里有一个关于计算总数的百分比。

For percentages please follow the tutorial on the Tech on the Net . 对于百分比,请按照Tech on the Net上的教程进行操作。

Adding another column where you calculate a difference between two pivot columns will not work - this column is "unpivotable", as it relies on a column defintion. 添加另一个用于计算两个透视列之间差异的列将不起作用 - 此列是“不可分割的”,因为它依赖于列定义。 You would need to copy and paste pivot as values to another worksheet and do the extra calculation there. 您需要将pivot作为值复制并粘贴到另一个工作表,并在那里进行额外的计算。

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

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