You are learning Power Query in MS Excel
How to clean and format data (remove leading/trailing spaces) in Power Query?
Here's how to clean and format data (remove leading/trailing spaces) in Power Query:
Method 1: Using Trim Function
1. Select the column: In the Power Query Editor, click on the column header containing the text data you want to clean.
2. Go to Transform: Navigate to the "Transform" tab.
3. Text Functions: In the "General" group, click on "Trim" from the dropdown menu.
This will automatically remove any leading and trailing spaces from the text in the selected column.
Method 2: Using Custom Column
1. Add Custom Column: Navigate to the "Add Column" tab and click "Custom Column."
2. Name the new column: In the formula bar, type a descriptive name for your new column (e.g., "CleanedText").
3. Enter the formula: Paste the following formula, replacing "ColumnName" with the actual name of your text data column:
```
= Text.Trim([ColumnName])
```
4. Change data type (optional): Click on the data type header of the new column and choose "Text" to ensure it recognizes the cleaned text data.
Both methods achieve the same result of removing leading and trailing spaces from your text data. Choose the method that best suits your workflow.
Additional Tips:
* You can repeat these steps for other columns that require space trimming.
* Power Query also offers functions like Text.Start and Text.End if you need to remove spaces from specific positions within the text.