You are learning Power Query in MS Excel
How to extract specific parts of text strings using text manipulation functions in Power Query?
Power Query offers a variety of text manipulation functions to extract specific parts of text strings. Here's a breakdown of commonly used functions and how they work:
1. Text.BeforeDelimiter:
This function extracts the portion of text before a specified delimiter.
* Example: Let's say you have a column named "Text" with values like "Product ID: ABC123". You want to extract the product ID (ABC123).
```
ExtractedProductID = Text.BeforeDelimiter([Text], ":")
```
2. Text.AfterDelimiter:
This function extracts the portion of text after a specified delimiter.
* Example: Continuing from the previous scenario, you can extract just the ID using:
```
ExtractedProductID = Text.AfterDelimiter([Text], ":")
```
3. Text.BetweenDelimiters:
This function extracts the text between two specified delimiters.
* Example: Imagine your data has filenames like "Invoice_2023_07.pdf". You want to extract the invoice number (2023_07).
```
InvoiceNumber = Text.BetweenDelimiters([Text], "_", ".")
```
4. Text.Split:
This function splits a text string based on a delimiter and returns a list of resulting substrings.
* Example: You have data with colors separated by commas (e.g., "Red,Green,Blue"). You want separate columns for each color.
```
ColorList = Text.Split([Text], ",")
```
5. Text.Start & Text.End:
These functions extract a specific number of characters from the beginning (Text.Start) or end (Text.End) of a text string.
* Example: Suppose you have website URLs (e.g., "[https://www.example.com](https://www.example.com)"). You want to extract just the domain name (example.com).
```
DomainName = Text.End([Text], Text.Length([Text]) - Text.IndexOf([Text], "//") - 3)
```
Additional Considerations:
* Handling Missing Delimiters: If a delimiter might be missing in some text strings, you can use functions like Text.Replace or Text.FillDown to pre-process your data for consistent delimiters.
* Combining Functions: Often, you'll need to combine multiple text manipulation functions to achieve the desired extraction.
By understanding these functions and their capabilities, you can effectively extract specific parts of text strings in your Power Query transformations!