A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Dear @PQ,
Thank you for posting your question in the Microsoft Q&A forum.
Based on my environment test and my understanding, please follow the steps below to prepare and transform your data effectively: Move your source data into the designated location or file where you will perform the transformation. Load the data into Power Query by selecting Data > Get Data > From Table/Range Your dataset may contain preliminary rows before the actual header row. Ensure that the row containing month names and key indicators (Sept 2024 Av, 30, 109,000.00) is promoted as the header.
Home > Use First Row as Headers. If necessary, use Remove Rows to keep only the three essential rows (Month/Indicator, Days, Revenue) before applying Transpose.
In Power Query Editor, go to Add Column > Custom Column and enter the following formula:
= Table.AddColumn(
#"Changed Type1",
"Rolling 12 Month Avg",
(CurrentRow) =>
let
// 1. Calculate the 'Monthly Value' for the current table
MonthlyValuesTable = Table.AddColumn(
#"Changed Type1",
"Monthly Value",
each [#"109000"] * [#"30"],
type number
),
// 2. Filter the table to include the 12 months before or including the current row's date
CurrentDate = CurrentRow[Sept 2024],
FilterDate = Date.AddMonths(CurrentDate, -11),
// 3. Select the 'Monthly Value' column from the filtered rows
RollingValues = Table.SelectRows(
MonthlyValuesTable,
each [Sept 2024] >= FilterDate and [Sept 2024] <= CurrentDate
)[Monthly Value]
in
// 4. Calculate the average of the rolling values
List.Average(RollingValues)
)
Note: Adjust column references in the formula to match your actual dataset structure.
If there’s anything I may have misunderstood, I would truly appreciate it if you could provide a bit more detail to help me better understand your needs. Also, if you’re stuck on anything or find something unclear, please feel free to reply so I can guide you further.
Looking forward to your response! If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.