Power BI · मराठी आवृत्ती
7.17 Unpivot आणि Pivot
Excel मध्ये प्रत्येक month चा वेगळा column असतो; Power BI analysis साठी Month आणि Value अशी long table अनेकदा सोयीची ठरते. खाली काल्पनिक monthly targets आहेत.
| City | Jan | Feb | Mar |
|---|---|---|---|
| Pune | 1200 | 1350 | 1500 |
| Nashik | 800 | 860 | 910 |
| City | Month | Target Orders |
|---|---|---|
| Pune | Jan | 1200 |
| Pune | Feb | 1350 |
| Pune | Mar | 1500 |
| Nashik | Jan | 800 |
| … | … | … |
- जसेच्या तसे ठेवायचे City सारखे columns निवडा.
- Transform › Unpivot Columns › Unpivot Other Columns करा.
- Attribute ला Month आणि Value ला Target Orders नाव द्या.
उलट Pivot करताना Month निवडा, Transform › Pivot Column, Values Column: Target Orders, आणि Advanced options मध्ये Sum किंवा योग्य असल्यास Don’t Aggregate निवडा. एका key साठी अनेक values असतील तर aggregation ठरवावी लागते.
Unpivoted = Table.UnpivotOtherColumns(Source, {"City"}, "Month", "Target Orders"),
Pivoted = Table.Pivot(Unpivoted, List.Distinct(Unpivoted[Month]), "Month", "Target Orders", List.Sum)
Unpivot Other Columns मध्ये fixed columns सोडून इतर सर्व unpivot होतात; April column पुढे जोडला तरी मिळतो. मात्र नवीन non-month metadata column आला तर तोही unpivot होईल, म्हणून schema तपासा.
Practice
Area आणि Blinkit / Amazon Now target columns असलेली table Area, Platform, Target Orders मध्ये unpivot करा. मग pivot करून values जुळतात का तपासा.