How to Extract Text in Excel Power Query: A Complete Guide

Learn how to extract text in Excel Power Query. Learn length, character extraction and delimiter text manipulation for data analysts and Excel power users.

Dynamic Date Example

by Mihir Kamdar / Last Updated:

Extract Text in Excel

What You'll Learn

After reading this guide, you’ll be equipped with the knowledge to:

  • Calculate text length for data validation
  • Extract specific characters from text strings
  • Master range-based text extraction
  • Implement delimiter-based text splitting
  • Handle complex text transformations

Download File

Download our step-by-step excel workbook file now by clicking on the icon  download icon 1  below and follow along to enhance your Excel skills practically and efficiently!

Introduction to Power Query in Microsoft Excel

In today’s data-driven world, the ability to data manipulation and extracting the text data efficiently is crucial. Power Query offers a robust set of tools for text extraction, making complex transformations of simple and automated data. This comprehensive guide will walk you through every text extraction technique available in Power Query.

What is Excel Substring Function

The Excel substring function refers to the use of functions like MID, LEFT, and RIGHT to extract a specific portion of text from a larger string based on a starting position and length. To return character from string in Excel, you can use the MID function, which extracts a specific character or substring starting from a given position within the text.

In Power Query, you can extract specific information from a text string by mails, such as isolating email addresses or domain names using delimiter-based techniques. The XLS substring function in Excel allows you to extract a portion of text from a cell by specifying the starting position and the number of characters you want to retrieve.

To extract text from a cell in Excel, you can use various functions like LEFT, RIGHT, or MID to isolate specific portions of the text based on the desired character positions.

If you’ve ever wondered what does nth mean in texting, it’s commonly used to mean ‘nothing’ and is often seen in casual conversations.

To excel get the second instance in the text, you can use a combination of Power Query functions that allow you to locate and extract specific occurrences of a word or phrase within a string.

To pull a cell using a string in Excel, you can use functions like INDEX or VLOOKUP, which allow you to search for a specific string and return the corresponding cell value from your data. With Power Query in Excel, you can easily extract text from a string using functions like Text.Start, Text.End, or Text.Range to isolate specific characters or substrings.

The Excel text extract function allows users to efficiently pull specific portions of text from a string using formulas like MID, LEFT, and RIGHT for customized data manipulation.

1. Getting Started with Power Query​

Power Query is a powerful data transformation and preparation engine that allows users to easily connect to various data sources, transform and clean their load data. To get started with Power Query, users can access it through the Power Query Editor in Power BI Desktop or Excel.

The Power Query Editor provides a user-friendly interface for connecting to data sources, applying transformations, and loading data. Whether you’re working with Excel files, databases, or web data, Power Query is use to import data and prepare it for proper analyzation. 

excel extract text from file
Excel: Free Masterclass​
Supercharge Your Skills For Free

2. Transformed Data and Its Cleaning

Data transformation and cleaning are critical steps in the data preparation process. Power Query provides a range of tools and techniques for transforming and cleaning data, including data profiling, data validation, and data cleansing.

Users can apply transformations to their data using the Power Query Editor, which provides a range of pre-built transformations and formulas. These tools help ensure that your data is accurate, consistent, and ready for analysis. From removing duplicates to correcting data types, Power Query makes it easy to clean and prepare your data. Power Query can help with data analytics once the raw text is transformed.

excel extract number from text string
Excel: Free Masterclass​
Supercharge Your Skills For Free

3. Length Calculation in Power Query Formula Language​

What is Length Function

The Length function is used for:

  • Data validation
  • Anomaly detection
  • Text extraction planning

 Step by Step

  1. Select the appropriate data source
  2. Select your column
  3. Go to Extract
  4. Choose Length
  5. Check results in the new column

Examples

  • Validate phone numbers
  • Check product codes
  • Ensure data completeness
excel extract text after character
Excel: Free Masterclass​
Supercharge Your Skills For Free

4. First Characters Extraction

What is First Characters Extraction?

This function extracts specified characters from the start of text strings.

Step by Step

  • Select your column
  • Go to Transform → Extract
  • Choose First Characters
  • Enter the number of characters
  • Preview and confirm

Use Cases

  • Extract country codes
  • Identify product categories
  • Capture prefix information
  • Extract specific characters from XML files using Power Query
how to extract text from a cell in excel
Excel: Free Masterclass​
Supercharge Your Skills For Free

5. Last Characters Extraction

What is Last Characters Extraction?

The Last Characters function extracts the specified number of characters from the end of text strings.

Step by Step

  • Select your column
  • Go to  Transform →Extract
  • Choose  Last Characters
  • Ensure data connections are intact to avoid issues with external data sources
  • Enter the number of characters
  • Preview and confirm

Use Cases

  1. Extract phone numbers
  2. Identify product categories
  3. Capture suffix information
extract text from excel cell
Excel: Free Masterclass​
Supercharge Your Skills For Free

6. Range Extraction

Master Range Extraction

This feature allows you to extract characters from specific positions within a text string.

Technical

  • Zero-based indexing
  • Flexible range selection
  • Custom length extraction

Step by Step

  • Select your column
  • Go to Transform → Extract
  • Choose Range
  • Enter character count
  • Apply
excel extract number from text
Excel: Free Masterclass​
Supercharge Your Skills For Free

7. Text Before Delimiter

Master Range Extraction

This feature allows you to extract characters from specific positions within a text string.

Technical

– Zero-based indexing
– Flexible range selection
– Custom length extraction

Step by Step

1. Select your column
2. Go to Transform → Extract
3. Choose Range
4. Enter the character count
5. Apply

excel extract text between two characters
Excel: Free Masterclass​
Supercharge Your Skills For Free

8. Text After Delimiter​

Text After Delimiter Extraction

This function is used to extract trailing information after a specified delimiter.

Step by Step

1. Select your column
2. Go to Transform → Extract
3. Choose Text After Delimiter
4. Enter the delimiter
5. Choose direction (from start/end)
6. Apply

Examples

– Extracting domain names
– Isolating last names
– Extracting file names

how to extract certain text from a cell in excel
Excel: Free Masterclass​
Supercharge Your Skills For Free

9. Text Between Delimiter

Advanced Delimiter Techniques

Extract text between two points using specified delimiters.

Step by Step

1. Select your column
2. Go to Transform → Extract
3. Choose Text Between Delimiters
4. Enter the start delimiter
5. Enter the end delimiter
6. Preview the results

excel extract text before character
Excel: Free Masterclass​
Supercharge Your Skills For Free

What are some common functions for extracting text in Power Query?

Common functions include Text.Start, Text.End, Text.Range, Text.BeforeDelimiter, Text.AfterDelimiter, and Text.BetweenDelimiters.

How do I extract the first few characters from a text string?

Use the Text.Start function. For example, Text.Start(“Hello World”, 5) returns “Hello”.

How can I extract text after a specific delimiter?

Use Text.AfterDelimiter. For example, Text.AfterDelimiter(“Hello-World”, “-“) returns “World”.

What if I need to extract text between two delimiters?

Use Text.BetweenDelimiters. For example, Text.BetweenDelimiters(“(Hello)”, “(“, “)”) returns “Hello”.

How do I extract a specific number of characters from the middle of a string?

Use Text.Range. For example, Text.Range(“Hello World”, 2, 5) returns “llo W”. The text range function is crucial to extract the specfic number from the middle of the string.

What is the data preparation process in Power Query?

The data preparation process in Power Query involves several key steps to clean, transform, and structure data for analysis. It includes importing data from various sources, removing unwanted columns or rows, correcting data types, handling missing values, and applying necessary transformations like sorting, filtering data, and aggregating data. Power Query simplifies these tasks with its intuitive interface and allows users to automate repetitive tasks, making data ready for analysis and reporting.

Can I automate data transformations in Power Query?

Yes, one of the key features of Power Query is the ability to automate data transformations. Once you set up your data transformation steps (such as cleaning, filtering, or aggregating), Power Query saves them as a series of applied steps in a query. Every time you refresh the query, Power Query will automatically reapply these steps to the new data, making the process of updating reports and dashboards much faster and less error-prone.

What is Excel Power Query and how is it used?

Microsoft Power Query is a data transformation tool that allows users to import, clean, and reshape data. It is integrated directly into Excel and helps automate complex data preparation tasks. Power Query is used to connect to various data sources, including Excel files, databases, and web data, and allows users to apply transformations without writing any code. The Power Query Editor in Excel offers an intuitive interface where users can select, clean, and manipulate data for further analysis, making it easier to work with large datasets.

Conclusion

Mastering text extraction in Power Query opens up powerful data transformation possibilities. Practice these techniques regularly, and you’ll handle complex text manipulations with confidence.

Facebook
X
LinkedIn
Pinterest
Email
Table of Contents

Office Tech Skill is a premier educational platform focused on Microsoft Office, providing professionals with the tools needed to thrive in the ever-evolving tech landscape.

© 2024 Office Tech Skill. All rights reserved