Automating a monthly Excel sales summary with Power Query, without writing macros
Power Query[1] is a feature built into Excel that collects data from files, folders, web pages and databases, shapes it into a usable form, and records each step so the steps can be repeated. The tutorial turns a café's monthly register export of more than 4600 rows into a table with one row per category, four rows in total.
The steps are: import the sales CSV files from a folder, keep only the checkout date-time, category and amount columns, add year and month columns, then group by year, month and category and sum the amount. The result is loaded into a new Excel sheet. The author notes that a single month could be summarized by hand with filters or formulas, and that the benefit of Power Query is that the steps are saved.
The author says Power Query needs no code, while macros[2] require VBA[3] code. Next month, the November CSV file is placed in the same folder and Refresh All is pressed, which adds four more rows to the table. The author also writes that generative AI can write macro code, but its results may vary between runs, while recorded Power Query steps repeat the same way.
Sources
-
JPZenn JA
Excelの「毎回同じ作業」を、Power Queryで更新ボタン一つにする——マクロを書かずにできる自動化





