fx Power Query Basics
ENहिन्दी

Core transforms: कॉलम हटाना, split, type बदलना, replace, fill down

⏱ 13 min

आप क्या सीखेंगे

  • हेडर प्रमोट करें और फ़ालतू रो हटाएँ
  • कॉलम हटाएँ — सुरक्षित तरीका
  • टेक्स्ट Trim और Clean करें

समझिए

1. हेडर प्रमोट करें और फ़ालतू रो हटाएँ

एक्सपोर्ट अक्सर टाइटल लाइनों से शुरू होते हैं। Home → Remove Rows → Remove Top Rows (जैसे 3), फिर Use First Row as Headers। खाली रो: Remove Rows → Remove Blank Rows।

2. कॉलम हटाएँ — सुरक्षित तरीका

जो कॉलम चाहिए उन्हें चुनें → राइट-क्लिक → Remove Other Columns।

= Table.SelectColumns(Source, {"OrderID", "OrderDate", "StoreID", "ProductID", "Qty", "UnitPrice", "Discount"})

"Other" क्यों? अगर अगले महीने एक्सपोर्ट में नया कॉलम जुड़े, तो वह अपने आप छूट जाता है। "Remove Columns" (नाम से) तब टूटता है जब हटाया गया कॉलम rename हो या न मिले।

3. टेक्स्ट Trim और Clean करें

Capstone के StoreID में लगभग 2% रो में पीछे स्पेस है ("S01 " ≠ "S01" — स्टोर लुकअप फ़ेल होगा)। StoreID चुनें → Transform → Format → Trim (और छिपे अक्षरों के लिए Clean):

= Table.TransformColumns(#"Removed Other Columns", {{"StoreID", Text.Trim, type text}})

4. Type बदलें — सही locale के साथ

कॉलम हेडर में टाइप आइकन पर क्लिक करें। dd-mm-yyyy वाली तारीख़ों (भारतीय एक्सपोर्ट) के लिए आइकन → Using Locale… → Date → English (India):

= Table.TransformColumnTypes(#"Trimmed Text", {{"OrderDate", type date}}, "en-IN")

नंबर सेट करें: Qty → Whole Number, UnitPrice → Fixed Decimal (currency) या Decimal, Discount → Decimal। लेसन 7 में और।

5. Replace values

Capstone के Discount में ~240 खाली (null) हैं। Discount चुनें → Transform → Replace Values: find null → replace 0:

= Table.ReplaceValue(#"Changed Type", null, 0, Replacer.ReplaceValue, {"Discount"})

टेक्स्ट replace भी ऐसे ही (जैसे "Bombay" → "Mumbai")। "Match entire cell contents" तभी हटाएँ जब टेक्स्ट का हिस्सा बदलना हो।

6. Split column

"Rahul Sharma" → First / Last: Transform → Split Column → By Delimiter → Space → Left-most delimiter। "S01-Delhi" → "-" से। Rows में split (Advanced options) "Laptop, Mouse" को दो रो में बदलता है — tidy data!

7. Fill down

Merged cells या "group header" वाले लेआउट की रिपोर्ट:

Region Store Sales
North Karol Bagh 500
(खाली) CP 450

Region चुनें → Transform → Fill → Down। खाली सेल असली null होने चाहिए — अगर वे खाली टेक्स्ट हैं, तो पहले Replace Values "" → null।

8. काम के कॉलम जोड़ें

  • Add Column → Custom Column: Revenue = [Qty] * [UnitPrice] * (1 - [Discount])
  • Add Column → Date → Month → Start of Month (मासिक grouping के लिए)
  • Conditional Column: if [Revenue] >= 50000 then "Big" else "Normal"

9. फ़िल्टर और डुप्लिकेट हटाना

कॉलम ड्रॉपडाउन फ़िल्टर AutoFilter जैसे चलते हैं, पर रिकॉर्ड होते हैं। चुने key कॉलम (जैसे OrderID) पर Home → Remove Rows → Remove Duplicates।

10. स्टेप का अच्छा क्रम

  1. टॉप/खाली रो हटाना, हेडर प्रमोट करना
  2. Remove Other Columns
  3. टेक्स्ट Trim / Clean
  4. Types बदलना (locale के साथ)
  5. Replace / fill down / split
  6. रो फ़िल्टर, डुप्लिकेट हटाना
  7. गणना वाले कॉलम जोड़ना
  8. स्टेप के नाम बदलना (राइट-क्लिक → Rename) ताकि लिस्ट डॉक्यूमेंटेशन जैसी पढ़ी जाए

आम गलतियाँ

टेक्स्ट trim करने से पहले type बदलना। Remove Other Columns की जगह Remove Columns। खाली null हों तब "" replace करना (या उल्टा)। "Changed Type3" जैसे अस्पष्ट स्टेप नाम छोड़ देना।

अभ्यास

mediumCapstone फ़ोल्डर query पर: Remove Other Columns (7 रखें), StoreID trim करें, en-IN locale से types सेट करें, null Discount को 0 से बदलें, Revenue custom column जोड़ें, डुप्लिकेट OrderID हटाएँ, और हर स्टेप का नाम बदलें। जाँचें कि StoreID में अब ठीक 8 अलग वैल्यू हैं (column profile: View → Column distribution)।
सात fields रखें; 1024 StoreIDs trim करें, dd-mm-yyyy को en-IN से पढ़ें, 239 null discounts को 0 करें और Qty*UnitPrice*(1-Discount) निकालें। 50000 unique OrderIDs, 8 stores, 12 products, दोनों वर्षों की revenue 560655230 हो। दूसरे multi-line data में केवल OrderID से rows न हटाएँ।

प्रश्नोत्तरी

फ़ालतू कॉलम हटाने का सुरक्षित तरीका?
Remove Other Columns
भारतीय dd-mm-yyyy टेक्स्ट तारीख़ें — कौन-सा विकल्प?
Change Type → Using Locale → English (India)
Fill Down कुछ नहीं करता — संभावित कारण?
खाली सेल null नहीं, खाली टेक्स्ट हैं
Core transforms: कॉलम हटाना, split, type बदलना, replace, fill down · हिंदी | ExcelWalaa