英文:
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.
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
这是您要翻译的内容:
=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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论