# 7.25 पूर्ण case study: messy export clean करूया

Source: https://ravindrabagale.com/mr/powerbi/ch07-data-cleaning-a-z-in-power-query/7-25-case-study-cleaning-a-messy-blinkit-export-end.html
Language: mr (Marathi with English technical terms)

काल्पनिक scenario: Operations head Rani ने Blinkit_Maharashtra_Export.xlsx दिली. दोन title rows, Total row, city spellings, ₹ text, Indian dates, काही UTC timestamps, duplicate lines आणि चुकीच्या values आहेत.

आधीचा sample आणि अपेक्षित result

 | Order No
 | Order Date
 | City
 | Amount
 | Mins
 | Phone

 | blk-81001
 | 20-10-2025
 | ·pune
 | ₹1,250
 | 9
 | +91 98220 12345

 | BLK-81001
 | 20-10-2025
 | Pune
 | ₹1,250
 | 9
 | +91 98220 12345

 | BLK-81002
 | 21-10-2025
 | Aurangabad
 | ₹ 86.50
 | NA
 | 09822054321

 | BLK-81003
 | 21-10-2025
 | Kolhapoor
 | 2,400
 | 500
 | 9822011111

 | BLK-81004
 | 22-10-2025
 | NASIK
 | ₹0
 | 0
 | 12345

 | Order ID
 | Order Date
 | City
 | Amount
 | Mins
 | DQ

 | BLK-81001
 | 20-Oct-2025
 | Pune
 | 1250.00
 | 9
 | OK

 | BLK-81002
 | 21-Oct-2025
 | Sambhaji Nagar
 | 86.50
 | null
 | Invalid time

 | BLK-81003
 | 21-Oct-2025
 | Kolhapur
 | 2400.00
 | 500
 | Too long

 | BLK-81004
 | 22-Oct-2025
 | Nashik
 | 0.00
 | 0
 | Invalid time

ही छोटी table फक्त काही columns दाखवते. पूर्ण exercise साठी Product ID, Store ID, timestamp आणि timezone ओळखण्याची माहितीही लागते. ती नसताना संबंधित steps चालणार नाहीत.

हा क्रम पाळा

View मधून पूर्ण dataset ची quality / distribution / profile तपासा.

दोन title rows काढा, headers promote करा आणि Total row filter करा.

Order No → Order ID; Mins → Delivery Time Mins rename करा.

Text Clean आणि Trim करा. Order ID UPPERCASE व City proper case करा.

CityMap Left Outer merge करून city names एकसारखी करा.

Amount मधले ₹, Rs., spaces, हजारांचे commas काढा आणि Fixed Decimal करा.

Order Date ला English (India) locale वापरून Date करा.

फक्त UTC असल्याचं निश्चित असलेले timestamps IST करा; मग Order Hour काढा. आधीच IST असलेल्या rows बदलू नका.

NA → null करा; conversion errors तपासून handle करा.

प्रत्यक्ष line key वापरून duplicates काढा; या exercise मध्ये Order ID + Product ID.

Phones standardise करा आणि Phone OK quality flag द्या.

Data Quality conditional column बनवा.

Product आणि DarkStore सोबत Left Anti करून unknown keys शोधा.

Steps rename, queries group, helper load बंद आणि dependencies तपासा.

Close & Apply नंतर rows व totals source शी reconcile करा.

Advanced Editor मधला संक्षिप्त code

let
    Source    = Excel.Workbook(File.Contents(FolderPath & "Blinkit_Maharashtra_Export.xlsx"), null, true),
    Sheet     = Source{[Item = "Orders", Kind = "Sheet"]}[Data],
    Skipped   = Table.Skip(Sheet, 2),
    Promoted  = Table.PromoteHeaders(Skipped, [PromoteAllScalars = true]),
    NoTotal   = Table.SelectRows(Promoted, each Text.StartsWith(Text.Upper(Text.Trim([Order No])), "BLK-")),
    Renamed   = Table.RenameColumns(NoTotal, {{"Order No", "Order ID"}, {"Mins", "Delivery Time Mins"}}),
    TextClean = Table.TransformColumns(Renamed, {
                   {"Order ID", each Text.Upper(Text.Trim(Text.Clean(_))), type text},
                   {"City",     each Text.Proper(Text.Trim(Text.Clean(_))), type text}}),
    CityFix   = Table.ExpandTableColumn(
                   Table.NestedJoin(TextClean, {"City"}, CityMap, {"Raw City"}, "M", JoinKind.LeftOuter),
                   "M", {"Clean City"}),
    CityStd   = Table.RemoveColumns(
                   Table.AddColumn(CityFix, "City Std", each [Clean City] ?? [City], type text),
                   {"City", "Clean City"}),
    Amounts   = Table.TransformColumns(CityStd, {{"Amount",
                   each Number.From(Text.Remove(Text.Replace(Text.From(_), "Rs.", ""), {"₹", ",", " "})), Currency.Type}}),
    NAtoNull  = Table.ReplaceValue(Amounts, "NA", null, Replacer.ReplaceValue, {"Delivery Time Mins"}),
    Typed     = Table.TransformColumnTypes(NAtoNull,
                   {{"Order Date", type date}, {"Delivery Time Mins", Int64.Type}}, "en-IN"),
    NoDupes   = Table.Distinct(Typed, {"Order ID", "Product ID"}),
    DQ        = Table.AddColumn(NoDupes, "Data Quality", each
                   if [Delivery Time Mins] = null or [Delivery Time Mins] <= 0 then "Invalid time"
                   else if [Delivery Time Mins] > 180 then "Too long" else "OK", type text)
in
    DQ

Code चालवण्याआधी: FolderPath parameter, Orders sheet आणि CityMap query तयार असली पाहिजे. FolderPath मध्ये आवश्यक path separator हवा. Product ID column हा पूर्ण source मध्ये हवा. हा shortened code आहे; सर्व checklist steps त्यात नाहीत. Output मधल्या City Std ला City rename करा. Empty Order No values असतील तर Text.StartsWith आधी null guard द्या.

सोप्या भाषेत

हे घर आवरण्यासारखं आहे. आधी junk rows बाहेर, मग headers व नावं जागेवर, मग spaces आणि spellings साफ, आणि शेवटी मोजणी. क्रम चुकला तर तेच काम पुन्हा करावं लागतं.

Cleaning दरम्यान control sheet ठेवा

Table नीट दिसते म्हणजे cleaning पूर्ण झाली असं नाही. प्रत्येक फरकाचं कारण सांगता आलं पाहिजे. कागदावर किंवा Excel मध्ये पुढच्या नोंदी करा:

Raw export मधल्या data rows मोजा; title / total rows वेगळ्या ठेवा. Export total लिहा.

Junk rows काढल्यानंतर count नेमका त्यांच्याइतकाच कमी झाला का पाहा.

Clean / Trim / case / CityMap नंतर row count बदलू नये. Merge मुळे वाढला तर mapping duplicates तपासा.

Duplicates काढल्यावर किती rows गेल्या आणि का ते लिहा.

Close & Apply नंतर Table view मधला count आणि card total शेवटच्या नोंदीशी जुळवा.

पूर्ण dataset profiling वापरा. Amount चा quick total पाहण्यासाठी temporary Statistics › Sum step करू शकता; तपासणीनंतर तो काढा किंवा वेगळी audit query ठेवा.

Worked example 1: Panchganga Gul Bhandar, Kolhapur

ही काल्पनिक दुकानाची October bills sheet आहे. शेवटचा space ␣ ने दाखवला आहे.

 | Bill No
 | Bill Date
 | City
 | Item
 | Amount

 | gb-501
 | 01-10-2025
 | kolhapur␣
 | Gul cubes 5 kg
 | ₹450

 | GB-501
 | 01-10-2025
 | Kolhapur
 | Gul cubes 5 kg
 | ₹450

 | GB-502
 | 01-10-2025
 | KOLHAPUR
 | Gul powder 2 kg
 | Rs. 220

 | GB-503
 | 02-10-2025
 | Ichalkaranji
 | Gul block 10 kg
 | ₹1,050

 | GB-504
 | 02-10-2025
 | Sangli
 | Gul cubes 5 kg
 | 450

 | Total
 | 
 | 
 | 
 | 2,620

 | टप्पा | Rows | Amount | काय बदललं?

 | Raw data — Total row वगळून | 5 | ₹2,620 | Export total एवढाच.

 | Bill No Clean / Trim / UPPER; City proper case | 5 | ₹2,620 | Values बदलल्या; count तोच.

 | Bill No duplicates काढल्यावर | 4 | ₹2,170 | GB-501 दोनदा होतं.

₹2,620 − ₹2,170 = ₹450, म्हणजे नेमकं एक duplicate GB-501 bill. Owner ला सांगता येईल: या sample मधला October total ₹2,170 आहे; ₹450 चं bill दोनदा नोंदवलं होतं. इथे एका bill ला एक row आहे म्हणून Bill No key चालतो. Item-line export मध्ये तोच नियम लावू नका.

Worked example 2: Nashik Valley Grapes

हा काल्पनिक exporter payment register आहे. Dates dd-mm-yyyy आणि amounts भारतीय grouping मध्ये आहेत.

 | Invoice
 | Paid On (text)
 | Amount (text)

 | NVG-11
 | 05-01-2026
 | 1,25,000

 | NVG-12
 | 13-01-2026
 | ₹ 86,400

 | NVG-13
 | 02-02-2026
 | Rs.2,10,500

 | पद्धत | 05-01-2026 | 13-01-2026

 | US locale वर Date conversion | चुकीचं 1 May 2026 | Error: month 13 नाही

 | Using Locale › Date › English (India) | 5 January 2026 | 13 January 2026

Rs., ₹, spaces आणि commas काढून Fixed Decimal केल्यावर 1,25,000 → 125000; ₹ 86,400 → 86400; Rs.2,10,500 → 210500. Total ₹4,21,900. पहिली date error न देता चुकीची होते, म्हणून sample dates डोळ्यांनीही तपासा.

नेहमीची चूक: cleaning आधी duplicates

gb-501 आणि GB-501 Power Query मध्ये वेगळे आहेत. आधी duplicate removal केलं तर दोन्ही टिकतात आणि ₹2,620 total चुकीचा राहतो. आधी Clean / Trim / UPPER करा; मग duplicates. Control sheet मध्ये 5 → 4 rows झाल्या पाहिजेत.

Mini-project

Nagpur आणि Solapur च्या काल्पनिक Amazon Now export वर हाच process करा; timestamps UTC असल्याचं स्पष्ट ठेवा. Deliverables: clean Orders query, CityMap, दोन anti-join quality queries आणि प्रत्येक Applied Step साठी एक ओळीची note.

Source rows, duplicates नंतरच्या rows आणि flagged rows हे तिन्ही counts नोंदवा. Loaded count वेगळा आला तर visuals बनवण्याआधी कारण शोधा.

Chapter recap

Junk rows → headers → text cleaning → values → types → duplicates. महत्त्वाच्या प्रत्येक टप्प्यानंतर count व total तपासा. अडकलात तर ही case study पुन्हा करा. पुढे नवीन columns तयार करायला शिकू.

रवींद्र बागले यांची tip

एका दिवसाचा आणि एका city चा Amount total मूळ export शी जुळवा. फरक असेल तर तो बदल करणारा step शोधा; फक्त table सुंदर दिसते म्हणून काम पूर्ण समजू नका.
