Shorten a Folder Path with a Power Query Custom Column
Question details
Extract the part of a folder path that follows a specified number of backslash delimiters.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- A query contains a Folder Path column, and the user wants a shorter path in a custom column.
- Observed behavior
- The desired result is the text after a chosen backslash, while retaining the original folder path.
Open the query in Power Query Editor and confirm that the column is named Folder Path. Count the backslashes in a sample path, including any in a drive root or network path.
Extract the Remaining Path with Text.AfterDelimiter
Use a custom column when you need the path after a specific backslash and want to keep the original column.
Text.AfterDelimiter uses a zero-based occurrence index: 0 selects the first backslash, while 6 selects the seventh.
In Excel, go to Data > Queries & Connections, then double-click the query to open Power Query Editor.
Select Add Column > Custom Column and enter a name such as Shortened Path.
In the custom column formula box, enter Text.AfterDelimiter([Folder Path], "\", 6). Change 6 to the zero-based index of the backslash you want to use.
Select OK, review the new column against a sample path, and choose Home > Close & Load to apply the query.

Work with Extracted Folder Paths in WPS Spreadsheet
WPS Office is a free, lightweight Office alternative with a familiar interface and support for Excel files, making it easy to move and edit spreadsheet results. Use Excel Power Query to create or refresh the custom M query; WPS does not fix that Power Query task.

Frequently Asked Questions
Why does the formula use 6 for the seventh backslash?
The occurrence index in Text.AfterDelimiter starts at 0. Enter 0 for the first backslash, 1 for the second, or 6 for the seventh.
What if the shortened path column shows an error?
Check whether the affected path contains the selected backslash. In Power Query Editor, select the custom column's gear icon under Applied Steps and adjust the occurrence index if needed.
Does the custom column replace the original folder path?
No. Add Column > Custom Column creates a separate column, leaving Folder Path available for comparison or later use.
Do backslashes at the beginning of a network path count?
Yes. Text.AfterDelimiter counts backslashes from the beginning of the text, including the leading backslashes in a network path.




