PQ Add Dynamic "Average" Column

alishern

New Member
Joined
Dec 9, 2017
Messages
29
Hello community!

I have a table of reports that gets updated every month. In the PQ editor I pivoted the report date column "REPORT PERIOD" which is in MM-YYYY format. And the data for it I used "Workload Data Input". I did that so it calculate s average of all inputs from each period for each item in the table. But the issue here is that when a new month data is inserted in the table, the average is not recognizing it. Here is the script in the PQ editor:

Pivot:
= Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#"REPORT PERIOD"]), "REPORT PERIOD", "Workload Data Input", List.Sum)

Inserted Average:
= Table.AddColumn(#"Pivoted Column", "Average", each List.Average({[#"08-2024"], [#"06-2024"], [#"05-2024"], [#"04-2024"], [#"03-2024"], [#"02-2024"], [#"01-2024"], [#"12-2023"], [#"11-2023"], [#"10-2023"], [#"09-2023"], [#"08-2023"], [#"07-2023"], [#"06-2023"]}), type number)

How do I make it dynamic so it picks up forthcoming new month entries?

Thank you very much!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
The way to avoid this problem, and many other similar problems, is to not pivot the data. Instead you should load data in long tables and keep the date column as an attribute of each row of data. Then, load it to the data model and use DAX measures to do the calculations you need and leverage the pivot table to get the tabulated output you desire.
 
Upvote 0

Forum statistics

Threads
1,224,810
Messages
6,181,079
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top