7. Data Cleaning A–Z in Power Query
7.3 Messy Excel Exports: Title Rows, Headers, Footers and Transpose
Start with a problem
The Pune export has a report title and a generated-time line above the real header, and a Total row at the bottom. Power BI reads all of them as data.
Explain simply
Shape the table first: Remove Top Rows, Use First Row as Headers, then remove the footer. A filter (Order ID begins with BLK-) is safer than Remove Bottom Rows when the footer size changes.
Show the data
Before:
| Column1 | Column2 | Column3 | Column4 |
|---|---|---|---|
| Blinkit Pune daily export (fictional practice data) | |||
| Generated 08-04-2026 07:00 IST | |||
| Order ID | Order Date | Store | Amount |
| BLK-401 | 06-04-2026 | "Kothrud " | ₹1,250 |
| BLK-402 | 06-04-2026 | baner | ₹980 |
| BLK-403 | 07-04-2026 | KOTHRUD | ₹450 |
| BLK-403 | 07-04-2026 | KOTHRUD | ₹450 |
| BLK-404 | Baner | ₹320 | |
| Total | ₹3,450 |
About this data: This table uses columns: Column1, Column2, Column3, Column4. This table uses columns: Rows, Last row. This table uses columns: Order ID, Order Date, Store, Amount. This table uses columns: Column1, Column2, Column3. Values shown are the lesson examples already on this page (not a new dataset).
Fictional sample data. Practice file: pq_raw_pune_export.csv (source: src/practice/).
Demonstrate
-
Home › Remove Rows › Remove Top Rows › 2 › OK.
Your result should look like this:
Row 1 Order ID -
Home › Use First Row as Headers.
Your result should look like this:
Rows 6 -
Order ID filter arrow › Text Filters › Begins With… ›
BLK-› OK.Your result should look like this:
Rows Last row 5 BLK-404 -
Rename the steps Removed title rows, Promoted headers, Kept order rows.
Show the result
Your result should look like this (fictional sample):
| Order ID | Order Date | Store | Amount |
|---|---|---|---|
| BLK-401 | 06-04-2026 | "Kothrud " | ₹1,250 |
| BLK-402 | 06-04-2026 | baner | ₹980 |
| BLK-403 | 07-04-2026 | KOTHRUD | ₹450 |
| BLK-403 | 07-04-2026 | KOTHRUD | ₹450 |
| BLK-404 | Baner | ₹320 |
Explain what happened
Remove Top Rows skips the title lines, Promote Headers uses the real header, and the BLK- filter drops the Total row however many footer lines there are.
Explore further
- Transpose fixes sideways reports (metrics in rows) – see the reference below.
Detailed reference for this lesson:
Friends, store managers often send Excel files like this. There is a report title, a blank line and the export date above the real header, and a total row at the bottom.
Before
| Column1 | Column2 | Column3 |
|---|---|---|
| Blinkit Kothrud – Daily Sales | null | null |
| Exported on 14-03-2025 10:05 IST | null | null |
| null | null | null |
| Order ID | Product | Amount |
| BLK-10001 | Gokul Cow Milk 500 ml | 32 |
| BLK-10002 | Kolhapuri Misal Masala | 85 |
| Total | null | 117 |
After
| Order ID | Product | Amount |
|---|---|---|
| BLK-10001 | Gokul Cow Milk 500 ml | 32 |
| BLK-10002 | Kolhapuri Misal Masala | 85 |
Steps in Power BI
- Home › Remove Rows › Remove Top Rows › Number of rows = 3 › OK.
- Home › Use First Row as Headers (also on Transform › Use First Row as Headers). Power Query adds a Promoted Headers step and usually a Changed Type step.
- Home › Remove Rows › Remove Bottom Rows › 1 (removes the "Total" line).
- To be safe when the number of footer rows can change, use a filter instead: click the Order ID filter arrow › Text Filters › Begins With… › "BLK-".
- Set the data types (Order ID and Product = Text, Amount = Whole Number or Decimal).
Skipped = Table.Skip(Source, 3),
Promoted = Table.PromoteHeaders(Skipped, [PromoteAllScalars = true]),
NoFooter = Table.RemoveLastN(Promoted, 1),
OnlyOrders = Table.SelectRows(Promoted, each Text.StartsWith([Order ID], "BLK-"))
Use Headers as First Row (the dropdown under Use First Row as Headers) does the reverse. It is handy before a Transpose (ओळी आणि स्तंभ उलटणे).
Transpose (Transform › Transpose) turns rows into columns. It is useful when a report is laid out sideways, for example metrics in rows and cities in columns:
Before
| Metric | Pune | Nashik | Nagpur |
|---|---|---|---|
| Orders | 1,240 | 610 | 705 |
| Stores | 5 | 2 | 2 |
After
| City | Orders | Stores |
|---|---|---|
| Pune | 1,240 | 5 |
| Nashik | 610 | 2 |
| Nagpur | 705 | 2 |
Steps: Transform › Use First Row as Headers › Use Headers as First Row → Transform › Transpose → Use First Row as Headers → rename Metric to City. (The numbers are practice values.)
Next we move on to duplicates – but first, do this Before/After table yourself in Power Query.
आता पुढे जाऊया duplicates कडे – पण आधी हा Before/After table स्वतः Power Query मध्ये करून बघा.
अब आगे चलते हैं duplicates की ओर – लेकिन पहले यह Before/After table ख़ुद Power Query में करके देखिए.
Ravindra Bagale's Tip
Friends, many students change the data type before promoting headers, so the header text causes errors, and they use Remove Top Rows with a fixed count that breaks when next month's file has an extra title row. Promote headers first, then set types. Where possible, filter by a pattern (for example rows that begin with "BLK-") instead of removing a fixed number of rows. Practise, and it will feel very easy.
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students headers promote करण्याच्या आधी data type बदलतात, त्यामुळे header text मुळे errors येतात, आणि ते fixed count सोबत Remove Top Rows वापरतात, जे पुढच्या महिन्याच्या file मध्ये एक जास्तीची title row आली की तुटतं. आधी headers promote करा, मग types set करा. शक्य असेल तिथे ठराविक rows काढण्याऐवजी pattern ने filter करा (उदाहरणार्थ "BLK-" ने सुरू होणाऱ्या rows). Practice करा, मग एकदम सोपं वाटेल.
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students headers promote करने से पहले data type बदल देते हैं, तो header text से errors आते हैं, और वे fixed count के साथ Remove Top Rows लगाते हैं जो अगले महीने की file में एक extra title row आते ही टूट जाता है. पहले headers promote करो, फिर types set करो. जहाँ हो सके, तय गिनती की rows हटाने की बजाय pattern से filter करो (जैसे "BLK-" से शुरू होने वाली rows). Practice करो, फिर बहुत आसान लगेगा.
Practice task
Take a Nagpur (Dharampeth) store export with 2 title rows and a "Grand Total" row. Clean it so that only order rows remain, then give every column the correct type.
Fix common mistakes
| Wrong result | Reason | Correction |
|---|---|---|
| Header row has Generated 08-04-2026… | Removed only 1 top row | Remove 2 |
| Total row still counted (₹3,450 + ₹3,450) | Footer not removed | Filter Begins With BLK- |
| Next file has 3 title rows and breaks | Fixed number of rows | Filter on a pattern, or ask for a stable export |
Practise independently
Practice task
Why might Remove Bottom Rows 1 fail next month?
Hints
- Footer could grow.
Solution
If the export adds a second footer line (for example Generated by…), one row is not enough; the BLK- filter handles any number.
Think like a professional
Design queries for the file you will get next month, not only for today's file.
Revision card