Power Query Intermediate Lesson 8: Project – ERP Register to HSN‑wise GST Summary

Power Query Intermediate Lesson 8: Project – ERP Register to HSN-wise GST Summary featured illustration

πŸ“Ž This article includes 3 downloadable practice files ↓

⏱ 2 min read

πŸ“˜ Power Query Intermediate Course Β· Lesson 8 of 8

Advertisement
In this article
  1. Steps
  2. Practice
  3. Continue learning

ERP exports often contain revised invoices: the same invoice number with Rev 1 and Rev 2. Summing everything double-counts them. This project produces a clean HSN summary from such a register.

Steps

  1. Import erp-register.csv and set types (Rev whole number, Date, Taxable, GST Rate).
  2. Latest revision only: Group By Invoice with Table.Max(_, "Rev") (lesson 4), expand.
  3. Add GST = Number.Round([Taxable] * [GST Rate], 2).
  4. Group By HSN and GST Rate: count of invoices, sum of Taxable, sum of GST.
Latest = Table.Group(Source, {"Invoice"}, {{"Row", each Table.Max(_, "Rev"), type record}}),
Rows   = Table.ExpandRecordColumn(Latest, "Row", {"Rev", "Date", "HSN", "Taxable", "GST Rate"}),
Tax    = Table.AddColumn(Rows, "GST", each Number.Round([Taxable] * [GST Rate], 2), type number),
Summary = Table.Group(Tax, {"HSN", "GST Rate"},
    {{"Invoices", each Table.RowCount(_), Int64.Type},
     {"Taxable",  each List.Sum([Taxable]), type number},
     {"GST",      each List.Sum([GST]), type number}})

The register has 30 rows but only 25 invoices; the summary correctly counts 25.

πŸ’‘ Load the summary next to last month’s and add a difference column. A sudden jump in one HSN is usually a wrong code in the ERP, and much cheaper to fix before filing than after.
⚠️ This is a practice summary. Check the current GSTR-1 HSN reporting rules (digits required, B2B/B2C split) for your turnover before using it for a return.

Practice

Unzip the source files (e.g. to D:\PQ\). Try to build the query with the ribbon first, then compare with the M solution and the expected result. Every solution was run by Excel’s own Power Query engine before publishing.

Advertisement

πŸ“Ž Practice files for this article

⬇ Download all 3 files (ZIP Β· 8 KB)

  • πŸ—‚οΈ
    Practice source files (zip)All messy CSVs for the course: invoices, payments, typed customer names, credit history, contacts, branch files, a two-row-header report and an ERP register.
    ⬇ ZIP Β· 3 KB
  • πŸ“„
    Lesson 8 M solutionThe full query. Paste into Advanced Editor and change the Folder line.
    ⬇ PQ Β· 1 KB
  • πŸ“—
    Expected resultWhat the query returned when Excel ran it, to compare with yours.
    ⬇ XLSX Β· 5 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong

Leave a Comment