I am new beginner of Power Query. My current raw data (1st screenshot below) consists of column headers (Column B - M) without [Year Name].
Column A | Column B | Column C | Column D | Column E | Column F | Column G | Column H | Column I | Column J | Column K | Column L | Column M |
Jan | Feb | Mar | Apr | May | June | July | Aug | Sept | Oct | Nov | Dec | |
Sales | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
Expense | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
I manually added in [2022] in Query Editor for all months (Jan - Dec). However, when come to next year, i will have to do the similiar manual exercise to replace col. header with [2023], which bit inefficient.
Table.RenameColumns(#"Removed Columns2",{"Jan", "Jan 2022"}, {"Feb", "Feb 2022"}, {"Mar", "Mar 2022}, {"Apr", "Apr 2022"}, {"May", "May 2022", {"June", "Jun 2022"}, {"Jul", "Jul 2022"}, {"Aug", "Aug 2022"}, {"Sep", "Sep 2022"}, {"Oct", "Oct 2021"}, {"Nov", "Nov 2022"}, {"Dec", "Dec 2022"}})
let's assume i key in "2023" in Excel Cell A1 in another worktab within same workbook.
Year |
2023 |
wonder if any better way which i can dynamic col. header name in P.Query Editor, base on [Year] selection from excel cell A1, and concentrate with [Month]?