Open In App

Text Modifications with Power Query in Excel

Last Updated: 27 Jan, 2023

A

Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

In Excel, Power Query is a business intelligence tool that is used to analyze the data imported from different sources. With the help of power query, we can easily clean, transform and reshape our data as per requirement along the way of analyzing the data. In this example, we will learn about the Text Functions which can be easily used with the help of Power BI for the modification of the data. Given below are the formatting functions that can be used to create and manipulate the text values.

Function Name

Description

Trim

It is used to trim(remove) the whitespace from both ends of the text.

Clean

It removes the non-printable characters from the text and returns it.

Merge Columns

It is used to combine two or more columns into a single column using a separator.

Lowercase

It is used to make text lowercase.

Uppercase

It is used to make text uppercase.

Add Prefix

It is used to add prefixes to a cell or set of cells.

Add Suffix

It is used to add suffixes to a cell or set of cells.

Capitalize Each Word

It is used to change a text into proper text.

Text Modifications with Power Query

Step 1: Create a Database.

In order to use the text operations, we will be using the following random names. 

Creating-database

Fig 1 – Database

In the above, we can see data is not clean, there is whitespace, some of the text start in lowercase and some are with uppercase. We will use the text formatting option to clean our data after that we will combine them in one column and then we will convert them into uppercase and lowercase.

Step 2: Open Power Query Editor.

In this step, we will open the power query editor window. For this Place Cursor in Table go to the Data tab at the top of the ribbon and then select From Table/Range option. Excel will open Power Query Editor.

opening-power-query-editor

 

Once we click on From Table/Range, Excel will automatically open the power query editor. Below, we can see in the power query editor window we have unwanted whitespaces.

power-query-editor-opens

 

Step 3: Remove Whitespaces.

In this step, we will remove the whitespace from both columns. For this Select Column then go to the Transform on the top of the ribbon then in the Text Column group choose Format and then select Trim.

Using-trim-function.

Fig 4 – Trim Function

Once we click on Trim option, excel will automatically remove the whitespaces from our column. Similarly, we need to do this for both columns. After we are done, we will get the following output.

After trim, we will get the following output.

 

Note: Whatever steps we do in Power Query Editor, all the steps are getting recorded in the APPLIED STEPS WINDOW. At any point in time, if we want to go back, we can use these steps.

applied-steps-window

 

Step 4: Combining Columns.

In this step, we will combine the two columns into a single column. For this Select Columns and then go to Transform on the top of the ribbon and then in the Text Columns group choose Merge Columns

combining-columns

Fig 7 – Merge Columns

Once we click on Merge Column excel, will open a window asking for the separator to be used while combining the columns. We can use any separator as per requirement (Here, we are using space as a separator while combining first and last name columns). Also, it will ask for the new columns name (Here, we are using Full Name as the new column name).

merging-columns

 

Once we click on OK, the power query will combine both columns into a single column with the name as Full Name.

full-name-merged-column

 

Step 5: Convert Text into Proper Text.

As we can see in the above picture, our data is not in proper form. Some of the letters are started lower and some of the words have uppercase letters in the middle. In this step, we will change our data into proper text. For this Select Column and then go to Transform on the top of the ribbon and then in the Text Columns group choose Format and then select Capitalize Each Word.

using-capitalize-each-word.

 

Once we click on Capitalize Each Word option excel will automatically convert our data into proper text.

proper-text

 

Step 6: Load Data into Excel Sheet.

Once we are done with our formatting, we can load our data from the power query editor to an excel sheet. For this go to the home tab on the top of the ribbon and then choose the Close & Load option.

using-Close-&-Load-option.

 

After we click on the Close & Load option, excel will create a new sheet and load our power query editor data into it.

Note: One of the important features of Power Query Editor is that, if we make any change in our original data, it will update the Power Query Editor’s generated data automatically once we refresh the sheet.

new-sheet-for-dataset

 



A

News
Improve
Discuss
Do you want to advertise with us?Click here to know more

C

Date Modifications with Power Query in Excel

A data preparation and transformation engine is Power Query. Power Query includes a Power Query Editor for implementing transformations as well as a graphical interface for obtaining data from sources. With Power Query (also referred to as Get & Transform in Excel), you may import or connect to external data and then modify that data to match your needs, for instance, by combining tables, altering the data type, or eliminating a column. When you're ready to produce charts and reports, load your query into Excel. You may periodically update the data by refreshing it. Steps to Open Power Query in Excel Step 1: First create a table in Excel. Step 2: Select the field and then navigate to the data tab on the top of the ribbon. Then select the Get data option and choose From other sources and select From Table/Range option. Step 3: Then Create Table dialog box appears. Here select the table range and then click OK. Step 4: Now you can see it converts the excel table to a power query Editor. Date modification with Power QueryAge The number of days between the specified date and the current date is determined when you choose the Age option and choose a date column. Next, you mu
Read More

Excel - Types of Merging of Queries in Power Query

article_img
In Power Query, we have an option to Combine two tables using “Merge queries”. Merge Queries: Merge with current query with another queryMerge Queries as New: Merge with current query with another query and create New query In this article, we explore different types of merging of queries in Power Query with two tables. We will combine two years of sales data (2020 and 2021) with the key field “Cust_ID”. Implementation: Follow the below steps to implement merging of queries: Step 1: Open Power Query Editor. Step 2: Select your Query “Sales_2020”. Go to Home >> Merge Queries >> Merge Queries as New. We have six type of joins: Left Outer (all from first, matching from second)Right Outer (all from second, matching from first)Full Outer (all rows from both)Inner (Only Matching rows)Left Anti (rows only in first)Right Anti (rows only in second) Step 3: Select Second table; Select key fields “Cust_ID” in both tables; Select Left Outer (all from first, matching from second) and Press “OK”. Step 4: Above step create a new query “Merge 1” as below in your power query. Note: Sales_2021 is not a text value it is a table for each row. Step 5: Click “Sales_2021” drop down icon; M
Read More

How to Create a Relative File Path with Power Query in Excel?

article_img
In today's digital environment, sharing Excel files effectively is vital. A common issue is that Excel's Power Query uses absolute file paths, which can break when files are opened on different systems. To enhance portability and maintain data connections, it's crucial to convert these absolute paths to relative paths. This article explains how to make Excel workbooks more shareable by using Power Query to switch from absolute to relative file paths. How to Create a Relative File Path with Power Query in Excel?Why Convert Absolute Paths to Relative Paths?Problem with Absolute Path: Absolute paths can cause issues when sharing files because the path is specific to the original user's computer. Due, to this file sharing, is a big and significant issue. For example, an analyst is analyzing data in its intelligence tools source via power query from your PC, the tools work well until the files are in your PC, but stop working as soon as they are imported into the third person PC, this happens because the absolute path in the third person computer might be different, and our power query files are still searching for the old absolute path provided in my computer. To resolve this issue, on
Read More

C

How to Add a Conditional Column in Power Query in Excel?

We may use Power Query to generate new columns whose values depend on one or more criteria that have been applied to existing columns in your database. The condition imposed on an existing column in the data model serves as the foundation for Power BI's conditional column. On the Add column tab, in the General category, is the Conditional column command. In this article, we are going to discuss the Conditional column in Power Query and in Power Pivot queries. Step By Step Implementation Step 1: Create an excel table with fields Roll No., Student name, and Marks. Step 2: Select a table. Then navigate to the data tab on the top of the ribbon and select the Get Data option and then go to from other sources and choose from Table/range. Step 3: Then create a Table dialog box appear. Here select the range and check my table has headers then click on OK. Step 4: Now as you can see the excel table is converted to a power query editor. Step 5: Now in the power query go to the add column tab on the top of the ribbon and here select the conditional column. Step 6: Add Conditional Column dialog box appears. Here write the new column name and then apply the if condition. Step 7: Her
Read More

D

How to Import, Edit, Load and Consolidate Data in Excel Power Query?

article_img
Power Query is an easy and efficient way of solving simple data tasks. Most of our valuable time is frequently consumed by tedious manual procedures like cut and paste, column merging, and filtering. These operations are greatly simplified with the Power Query tool. A further advantage is that, in comparison to other BI tools, Power Query is simple to use. The Power Query user interface is straightforward. Given how much it resembles the Excel interface, many users will find it to be familiar. What is Power Query? Power Query is an application for preparing and transforming data. Using Power Query, you may perform transformations to data obtained from sources using a Power Query Editor and a graphical user interface.  We can import data from a variety of sources, clean it, convert it, and then reshape it to suit our needs using Power Query, a business intelligence tool provided by Microsoft Excel. Power Query allows us to create a query just once and reuse it later by simply refreshing it. Different Ways to Import Data to the Excel Sheet Excel allows importing data from a variety of sources. We will look at each of these in detail. While importing data, power query has several feat
Read More

How to use Power Query as a Pivot Table Data Source?

article_img
Power Query is a tool that is available in Microsoft Excel that simplifies the process of importing data from different sources and sorting them into an Excel sheet in the most convenient and usable format. It is a tool in Microsoft Excel that is used to simplify the process of importing data from different source files and sorting them into an Excel sheet. It also removes the need to do the same filtering techniques to transform the same data set at different points as per requirement; the user only needs to set up a query, that is, the rules for sorting, once, and refresh the query every time you need to perform a particular action. So, you can easily use a power query once and simplify your data rather than using it again and again. The biggest advantage you get when you use the Power Query is higher efficiency. A pivot table is aggregated value such as the sum, average, minimum, and maximum of a large dataset to represent the dataset in a concise manner. Pivot tables are generally used to represent the Summary of large datasets. The input of Power Query effectively helps to put large datasets in the proper format for the pivot tables to process data. Steps to implement Power Qu
Read More

How to Merge Content of All Files in Folder with Power Query?

article_img
Use Power Query to create a single table from numerous files with the same schema that are saved in the same folder. For instance, you could wish to merge budget workbooks from several departments each month when the columns are the same but the workbooks have different numbers of rows and values. Once it is configured, you may add further transformations, just as you would with any other single imported data source, and then refresh the data to view the results for each month. Merging Content of All Files Suppose we have multiple files in a folder that contains consistent types of data, with the help of power query we can merge all the data together with the help of power query easily. Let's say there is a folder "Student" that contains several files that contain information about the students in the form of a table. We need to merge all the student details from all the files into a single file. As far as all the files are consistent, which means hold similar kind of tables only, merging all the details are very easy. Steps to Merge Content of All Files in Folder with Power Query Step 1: Open Excel and then go to the Power Query on the top of the ribbon and then select From File
Read More

Power Query – Source Reference as File Path in Cell

article_img
Power query helps in doing automation in an efficient manner. It allows users to utilize files stored in specific locations and apply routine transformation steps on those files. It allows users to embed file paths and file sources in an Excel cell. The end user can make use of named ranges and Excel cells as references to access multiple files. In this article, we will learn how to refer to Source as a file path in a cell.  Adding Source Reference as File Path in Cell Let us take a basic example of how to make use of Excel cells in manipulating file paths. Below is an example where 2 Excel files are there, Power query1.xlsx and Power query2.xlsx.  The reference to source as file path, is only valid if the excel files, have same table name, and same number of columns in it. For example, Power query1.xlsx and Power query2.xlsx, has same table name(Table_src) and same number of columns.  Step 1: In the above example, Excel cells B2 and B3 contain the path of the Excel file. Let us bring the data to be used for transformation. The name of cell B2, should be replaced with FileP, as shown in the image below. FileP will be the name range cell of B2.  Step 2: To do this, go to the Data ri
Read More

Editing Excel Macros in Excel

article_img
Excel Macro is a set of actions that can be recorded, saved, used multiple times. This feature saves us a lot of time when dealing with repetitive tasks and huge data sets. We can always make changes to an existing Macro in Excel. There are two ways to record and run macros: Excel Commands Excel Visual Basic for Applications(VBA).1. Copying a Macro Code We can reuse the existing macro code while creating new Macros. For example, if you have existing macros created using the record function, we can reuse the code to write new macros. To open the code follow the below steps: Select Tools --> Macros --> Visual Basic Editor. Copy code from the existing macros(use Command + C) and paste(use Command + V) in the new macro2. Renaming a Macro Follow the below steps to rename a Macro in Excel: Select Tools --> Macros --> Visual Basic Editor. Select name on the left plane.Edit the name.3. Deleting a Macro Follow the below steps to delete a macro in Excel: Select Tools --> Macros --> Macros... Select the macro to be deleted. Click on the minus(-) symbol at the bottom.Select yes to delete the macro.
Read More

Best Microsoft Excel High-Paying Jobs with Excel Skills in 2024

article_img
Are you ready to unlock a world of opportunities with Microsoft Excel? In today’s data-driven job market, mastering Excel is essential for launching a successful career, whether you're a fresher or an experienced professional. In this article, we will cover the high-paying Excel jobs available in 2024, including crucial roles like data analyst, business analyst, and many more. We'll explore the qualifications needed for these positions, along with salary estimations to help you understand your earning potential. Whether you’re looking for Excel jobs for freshers or seasoned professionals, we’ll also dive into options for Excel freelancing jobs and work-from-home jobs in Excel. Equip yourself with the knowledge to excel in your career and take the first step toward a lucrative future!Best Microsoft Excel High-Paying Jobs with Excel Skills in 2024Table of ContentWhy choose a career in ExcelWhy Excel Skills Are Essential for Your CareerEssential Excel Skills Required to Boost Your Resume Best Microsoft Excel High-Paying JobsFinancial AnalystsData AnalystAdministrative Assistant Accountants Project ManagersManagement ConsultantRetail Store ManagersBusiness Analyst Market Research A
Read More
three90RightbarBannerImg