YUNOVA · Excel for work
Module 21: Advanced Power Query
Combine monthly files from folder
Key points
- Data > Get Data > From File > From Folder > folder चुनें > Combine & Transform Data—folder की सारी files एक table में।
- Power Query Sample File से steps बनाकर हर file पर लगाता है, इसलिए सब files का structure एक जैसा हो।
- Source.Name बताता है row किस file की है (month निकालने में काम आता है)। ~$ वाली temporary files filter से हटाएँ।
- अगले महीने नई file उसी folder में डालें और Refresh करें। Folder का path बदला तो Source step में नया path देना होगा।
Unpivot/normalize headers
Key points
- Wide data (हर month का अलग column) Pivot/SUMIFS के लिए ठीक नहीं। Unpivot उसे long बनाता है: Product | Month | Sales।
- Product जैसे ID columns select > Transform > Unpivot Other Columns; बने Attribute और Value को rename करें।
- "Unpivot Other Columns" चुनें, "Unpivot Columns" नहीं: अगले महीने नया Apr column आए तो वह भी अपने-आप unpivot होगा।
- पहले headers साफ़ करें: Use First Row as Headers, दो-line headers जोड़ें, और Total column/row unpivot से पहले हटाएँ।
Grouping/custom M/parameters/error handling (G7 only)
Key points
- Transform > Group By: Region से group करके Sales का Sum, Count Rows आदि। Advanced में एक साथ कई aggregations।
- Custom Column में M: [Qty] * [Price]। M case-sensitive है: if … then … else छोटे अक्षरों में, Text.Upper सही।
- M में error: try Number.From([Amount]) otherwise 0। पूरे column पर Replace Errors; जाँच के लिए Keep Errors।
- Home > Manage Parameters से FolderPath जैसा parameter बनाकर Source step में इस्तेमाल करें—path एक जगह से बदलेगा।