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.
या practice चं ध्येय: Power Query ने दोन wide files एकत्र करा आणि refresh होणाऱ्या एका table मध्ये city-wise orders मिळवा.
इस practice का लक्ष्य: Power Query से दो wide files जोड़ें और refresh होने वाली एक table में city-wise orders पाएँ.
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
| 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):
- Load both files with Data › Get Data, choose Transform Data.
- In each query, select City and click Transform › Unpivot Columns › Unpivot Other Columns.
- Rename Attribute to
Monthand Value toOrders. - Add a custom column
Platformwith the platform name in each query. - Click Home › Append Queries › Append Queries as New.
- In the appended query, click Transform › Group By: group by City, Sum of Orders.
- 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.