Power Query Problems

Shorten a Folder Path with a Power Query Custom Column

Emma BrownEmma Brown Dec 2, 2026 868 views

Question details

Extract the part of a folder path that follows a specified number of backslash delimiters.

Shorten a Folder Path with a Power Query Custom Column
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the query

In Excel, go to Data > Queries & Connections, then double-click the query to open Power Query Editor.

2
Add a custom column

Select Add Column > Custom Column and enter a name such as Shortened Path.

3
Enter the formula

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.

4
Check and apply the result

Select OK, review the new column against a sample path, and choose Home > Close & Load to apply the query.

Extract the Remaining Path with Text.AfterDelimiter
Check the delimiter count: Paths with fewer than seven backslashes can return an error with the example formula. Choose an occurrence that exists in the paths you are processing.
Free Microsoft Office alternative

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.

Open and edit extracted folder-path results in WPS SpreadsheetCompatible with Microsoft Excel XLSX and XLS filesFamiliar spreadsheet interface for a smooth transitionFree and lightweight Office alternative
microsoft office alternative - wps office

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.