Replace Values in Excel Query Source
In data processing, you may want to replace values displayed in a certain format, but don’t know how to do it. Don’t worry, in this article, I will guide you on how to replace values in the query source in Excel. Let’s refer to the steps below!
Replace Values in Power Query
I have the following data:
Topic requirement: Change the values in the Product column to numeric format.
To fulfill this requirement, you need to follow these steps:
Step 1: First, your data must be converted to a table format. To create data in Table format: Select any cell in the data range, then go to the Insert tab, select Table or press Ctrl + T and click OK.
Step 2: Go to the data query interface by selecting From Table/Range in the Data tab.
Display the Power Query Editor interface. Here, you will identify the object to be processed, as per the requirement to change the values in the Product column to numeric format. Therefore, you will select the Product column by clicking on the column header name.
Step 3: On the toolbar, go to the Transform tab and select Replace Values.
Step 4: The Replace Values table will be displayed. In the Value To Find field, type the content you want to replace, and in the Replace With field, type the content that will replace it.
In the example above, since I want to remove the “SP” character and leave only the number, I will set Replace With as a space.
Step 5: Click OK to complete.
Note: If you want to display “SP-01” to differentiate the product code behind, in the Value To Find field, type “SP”; in Replace With, type “SP-“.
And click OK to complete.
Step 6: To convert the data in the Product column to a numeric format, you will select the Product column header name to select the column, then go to the Transform tab and select Data type: Whole Number.
However, after converting the data, you may encounter a case where there is an Error displayed.
To fix this error, you will do the following: Go to the Transform tab, select Replace error.
The Replace Errors table will be displayed, where you will enter the value to replace when an error occurs.
And click OK, the error will be replaced immediately with another value.
Step 6: To export the data to Excel file, go to the Home tab and select Close & Load.
The exported data will be displayed in a new sheet.
So I have finished instructing you on how to replace values in the query source in Excel. Hopefully, this article will be helpful for you. If you find this article useful, don’t forget to rate it below!