Ravindra BagaleCourses & study guides मराठी Track your progress

10. Power Query in Excel

Practice and Answer Key: Append, Unpivot and Group By

Goal of this practice: Combine two wide files with Power Query and get orders per city in one refreshable table.

Suppose Ravina gets two small files every month: Blinkit orders and Amazon Now orders, typed with months as columns. She wants orders per city for both platforms together. All data is fictional.

Blinkit file

About this data. The rows in this practice on Append, Unpivot and Group By are made up. The people, shops and amounts are fictional, so you can try the steps safely. Any business name here is not a real company.
City Oct Nov
Pune 120 135
Nashik 80 90

Amazon Now file

City Oct Nov
Pune 60 70
Nagpur 50 65

Exercise (one under the other):

  1. Load both files with Data › Get Data, choose Transform Data.
  2. In each query, select City and click Transform › Unpivot Columns › Unpivot Other Columns.
  3. Rename Attribute to Month and Value to Orders.
  4. Add a custom column Platform with the platform name in each query.
  5. Click Home › Append Queries › Append Queries as New.
  6. In the appended query, click Transform › Group By: group by City, Sum of Orders.
  7. Click Close & Load.

Expected result (check your numbers):

City Orders
Nagpur 115
Nashik 170
Pune 385

The appended long table has 8 rows. Total orders = 670.

Answer key (open after you try)
Each query: Unpivot Other Columns (keep City) → rename Attribute = Month, Value = Orders
Add Column › Custom Column: Platform = "Blinkit"   (or "Amazon Now")
Home › Append Queries as New: Blinkit + Amazon Now
Transform › Group By: City · New column Orders = Sum of Orders

Pune appears in both files, so its orders add up: 120 + 135 + 60 + 70 = 385.

Common mistakes:

What you see Why Fix
Month values look like "Column2" Headers were not promoted Home › Use First Row as Headers before unpivoting
Some rows show null Orders after Append Column names differ (Orders vs orders) Rename to exactly the same name in both queries
A new Dec column is ignored next month Unpivot Columns was used on Oct and Nov only Use Unpivot Other Columns with City selected
Pune shows twice in the result Group By was done before Append Append first, then Group By

Ravindra Bagale's rule: shape each file the same way first, then append, then summarise.

Thodkyaat sangaycha tar (quick recap)

Power Query mhanje cleaning steps record karun Refresh ne punha chalvne: Excel/CSV/Folder madhun data (dates la locale English (India)), bank statements folder madhun combine, Append = khali jodne (column nava same), Merge = join (key duplicate nako, Left Anti ne missing shodha), Unpivot Other Columns, Group By, path sathi parameters, aani staging queries connection-only. Aata pudhe jaauya – what-if analysis.