# 7.12 Extract: text मधला हवा तो भाग

Source: https://ravindrabagale.com/mr/powerbi/ch07-data-cleaning-a-z-in-power-query/7-12-extract-length-first-last-characters-range-and.html
Language: mr (Marathi with English technical terms)

Transform › Extract existing column बदलतो. Add Column › Extract नवीन column बनवतो. खाली functions, inputs आणि outputs आहेत.

 | Extract option
 | Input
 | Output
 | M function

 | Length
 | Kolhapuri Misal Masala
 | 22
 | Text.Length

 | First Characters (3)
 | BLK-10001
 | BLK
 | Text.Start([Order ID], 3)

 | Last Characters (5)
 | BLK-10001
 | 10001
 | Text.End([Order ID], 5)

 | Range (start 4, 3 chars)
 | BLK-PUN-KOT-01
 | PUN
 | Text.Middle([Store ID], 4, 3)

 | Text Before Delimiter "@"
 | shraddha.bagale@example.com
 | shraddha.bagale
 | Text.BeforeDelimiter

 | Text After Delimiter "@"
 | shraddha.bagale@example.com
 | example.com
 | Text.AfterDelimiter

 | Text Between Delimiters "(" ")"
 | Blinkit Baner (Pune)
 | Pune
 | Text.BetweenDelimiters

दुरुस्ती: Kolhapuri Misal Masala ची length spaces धरून 21 आहे; source example मधला 22 हा typo आहे. Length मोजताना प्रत्यक्ष string तपासा.

Store ID निवडा.

Add Column › Extract › Range निवडा.

Starting Index 4 आणि Number of Characters 3 द्या. Index 0 पासून मोजला जातो; त्यामुळे 4 म्हणजे पाचवं character.

Column ला City Code नाव द्या.

Delimiter extraction च्या Advanced options मध्ये start / end पासून search आणि किती delimiters skip करायचे ते ठरवता येतं. शेवटच्या - नंतरचा Store No काढण्यासाठी code पाहा.

AddCode  = Table.AddColumn(Source, "City Code", each Text.Middle([Store ID], 4, 3), type text),
LastPart = Table.AddColumn(AddCode, "Store No", each Text.AfterDelimiter([Store ID], "-", {0, RelativePosition.FromEnd}), type text)

Practice

Customer e-mail मधून @ नंतरचा domain काढा. Amul Butter 100 g मधून शेवटच्या space नंतरचं unit काढा.

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

BLK-1 आणि BLK-10001 सारखी लांबी बदलत असेल तर fixed Range चुकू शकतो. Delimiter-based extraction योग्य ठरू शकतो. फक्त पहिल्या पाच rows नव्हे, विविध samples पाहा.
