I am new to using DAX but have gone down that rabbit hole today trying to solve this. The dates of the pivot table are grouped and set up so that the Month is in the Rows section of the pivot table and Years are the columns. Ideally, I would like to have a "Grand Total" column that shows the average number seen in each of the 5 years prior to the current one on a monthly basis and then add this column to the relevant PivotChart in order to compare the monthly data I have seen this year to the average seen over the prior 5 years. Is there a way to do this with DAX?
I tried creating a Power Pivot Measure and the adding the measure to the Values section of the pivot table. The data I wanted to see was joined by an additional column in each year for the 5-year average, which I do not want.
=CALCULATE(
AVERAGE([Crude (excluding SPR)]),
PARALLELPERIOD(US_Stocks_Monthly_Avg[Date],-5,YEAR))
Added Details #1
Below is a screenshot of the pivot table in its current form. This pivot table is called: PivotTable1
[Current pivot table layout]
Below is a screenshot of the table that the pivot table is pulling data from. This table is called: US_Stocks_Monthly_Avg
[Data source table]
Added Details #2
I have created a separate table for consecutive dates going from oldest to largest that you can see below. This table is called: Monthly_Dates_Table
I then added this table to the Data Model and created a relationship between the Date field in the data source table and the new dates table. An image of this relationship in the Power Pivot Data Model can be seen below. The arrow points away from the dates table ("Monthly_Dates_Table") and towards the data source table ("US_Stocks_Monthly_Avg"). Is that the correct direction for the connection? I have also attached an image of the data view of the Monthly_Dates_Table in the Data Model.
I tried to create the Measures I am looking for but was confused about which table I should be referring to for time intelligence purposes now that there are two tables with dates.
I added the Date field from the Monthly_Dates_Table to the pivot table and proceeded to group the dates together by month and year and create the same layout as before that refers to the dates in the Monthly_Dates_Table. Let me know if this step was premature.
[Current pivot table v2]