在Power Query数据透视表中创建一个用于上个月费用的DAX度量。

huangapple go评论77阅读模式
英文:

Creating a DAX measure for previous month charges in Power Query Pivot Table

问题

I'm using Power Query to pull some billing information from a Sharepoint Folder. The fisrt image shows this table.

我正在使用Power Query从Sharepoint文件夹中提取一些计费信息。第一张图片显示了这个表格。

I then want to summarise this with a Pivot Table based on the billing period.

然后,我想根据计费周期使用数据透视表对其进行汇总。

The second image shows my pivot table. I'm trying to create a measure 'Previous Month' that will give me the Total Charges for the previous month for each row - however I'm struggling. Please note - sometimes the different companies will be billed on different date periods - I still wish this to be based on the month the Bill Period End Date falls in.

第二张图片显示了我的数据透视表。我试图创建一个名为“Previous Month”的度量,该度量将为每一行提供上个月的总费用 - 但我遇到了困难。请注意 - 有时不同的公司将在不同的日期周期内收费 - 但我仍希望基于账单周期结束日期所在的月份来计算。

This is the measure that I've created, but as you can see it only provides the 'Apr' value in the Grand Total.

这是我创建的度量,但正如你所看到的,它只在总计中提供了“Apr”值。

=CALCULATE( SUM(Billing[Total Charges excl. Vat]), FILTER(Billing, Billing[Billing Period End Date (Month Index)] = MAX(Billing[Billing Period End Date (Month Index)])-1) )

我创建的度量如上所示,但如您所见,它只在总计中提供了“Apr”值。

英文:

I'm using Power Query to pull some billing information from a Sharepoint Folder. The fisrt image shows this table.

I then want to summarise this with a Pivot Table based on the billing period.

The second image shows my pivot table. I'm trying to create a measure 'Previous Month' that will give me the Total Charges for the previous month for each row - however I'm struggling. Please note - sometimes the different companies will be billed on different date periods - I still wish this to be based on the month the Bill Period End Date falls in.

在Power Query数据透视表中创建一个用于上个月费用的DAX度量。

在Power Query数据透视表中创建一个用于上个月费用的DAX度量。

This is the measure that I've created, but as you can see it only provides the 'Apr' value in the Grand Total.

=CALCULATE(
SUM(Billing[Total Charges excl. Vat]), 
FILTER(Billing,
Billing[Billing Period End Date (Month Index)] = MAX(Billing[Billing Period End Date (Month Index)])-1)
)

I've searched several forums but cannot find an answer.

Invoice Date Billing Period Start Date Billing Period End Date Company Name Total Charges Excl VAT Billing Period End Date (Year) Billing Period End Date(Quarter) Billing Period End Date (Month Index) Billing Period End Date (Month)
06/02/2023 01/03/2023 31/03/2023 Company A 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 10.35 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company A 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 27.10 2023 Qtr2 3 Mar
06/02/2023 01/03/2023 31/03/2023 Company B 11.10 2023 Qtr2 3 Mar
05/05/2023 01/03/2023 31/03/2023 Company B 11.10 2023 Qtr2 3 Mar
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company A 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company A 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company A 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company A 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company A 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 11.10 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 29.00 2023 Qtr2 5 May
05/05/2023 01/05/2023 31/05/2023 Company B 29.00 2023 Qtr2 5 May
04/04/2023 01/04/2023 01/04/2023 Company A 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 29.00 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company B 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 9.71 2023 Qtr2 4 Apr
04/04/2023 01/04/2023 01/04/2023 Company A 9.71 2023 Qtr2 4 Apr

答案1

得分: 1

这是您要翻译的内容:

在Power Query数据透视表中创建一个用于上个月费用的DAX度量。

=VAR p = CALCULATE(MAX(Billing[Billing Period End Date (Month Index)])-1)
VAR s = CALCULATE( SUM(Billing[Total Charges Excl VAT]),FILTER(ALL(Billing),Billing[Billing Period End Date (Month Index)] = p))
RETURN
IF(HASONEVALUE(Billing[Billing Period End Date (Month Index)]), s)

英文:

Here you go.

在Power Query数据透视表中创建一个用于上个月费用的DAX度量。

=VAR p = CALCULATE(MAX(Billing[Billing Period End Date (Month Index)])-1)
VAR s = CALCULATE( SUM(Billing[Total Charges Excl VAT]),FILTER(ALL(Billing),Billing[Billing Period End Date (Month Index)] = p))
RETURN
IF(HASONEVALUE(Billing[Billing Period End Date (Month Index)]), s)

huangapple
  • 本文由 发表于 2023年5月25日 19:40:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76331875.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定