Preserve Hyperlinks When Refreshing SQL Data in Excel Power Query
Question details
Create hyperlinks that remain connected to the correct SQL query records after an Excel Power Query refresh.

- Product
- Microsoft Excel Power Query with a SQL data source
- Device & OS
- not provided
- Scenario
- The user refreshes a SQL query table and needs each returned code or key to link to a related file, folder, or webpage.
- Observed behavior
- Manually inserted hyperlinks can be removed or become misaligned when the refresh adds, removes, or reorders rows.
Make sure the SQL query returns a stable field, such as a code, ID, or file key, that can be used to construct each destination address. Identify the consistent URL or folder-path pattern and file extension before adding the formula.
Create a dynamic HYPERLINK formula beside the query table
Use this method when each SQL record has a code or key that can be combined with a fixed folder path, URL, or filename pattern.
A formula-based hyperlink is calculated from the current row's query result instead of being manually attached to a row. When Power Query refreshes the table, the formula can continue to generate the correct link for each returned record.
In the Excel query output table, identify the column containing the code, ID, or filename component needed to create the link.
Insert a column immediately to the right of the query table, then enter a header such as Link or Open File. Keeping the formula adjacent to the query output helps Excel maintain it with the refreshed rows.
In the first data cell of the new column, enter a formula such as =HYPERLINK("\\Server\SharedFolder\"&[@Code]&".pdf","Open file"), replacing [@Code], the path, extension, and display text with your own values. For a web address, use a pattern such as =HYPERLINK("https://example.com/files/"&[@Code],"View record").
Press Enter and allow Excel to fill the calculated column, or drag the fill handle if needed. Confirm that each link opens the destination associated with that row's returned code.
Select Data > Refresh All, then check newly added, moved, and retained rows. The hyperlink text should be regenerated from the refreshed row values.

Return the link target from SQL and use Excel only for the clickable label
Use this option when the full URL or file path can be generated reliably in the SQL query or Power Query transformation.
Create Dynamic Hyperlinks in WPS Spreadsheet
If Excel Power Query refresh behavior is interrupting your workflow, WPS Office is a free, lightweight Office alternative with a familiar spreadsheet interface. You can open and edit compatible Excel workbooks, use HYPERLINK formulas to generate row-based links, and move existing spreadsheet work to WPS Office with minimal adjustment.

Frequently Asked Questions
Why do manually inserted hyperlinks disappear after an Excel query refresh?
A refresh can rebuild or resize the query output range, so hyperlinks manually attached to individual cells may not remain associated with the refreshed records. A formula using HYPERLINK is recalculated from the current row data instead.
Where should I put a HYPERLINK formula next to a Power Query table?
Add the formula in a column immediately to the right of the loaded query table. Use the table's current-row reference, such as [@Code], so the link is generated from the value in the same row.
Can I create hyperlinks from a network folder and a SQL code?
Yes. Combine the shared folder path, the returned code, and the extension in a formula, for example =HYPERLINK("\\Server\Folder\"&[@Code]&".pdf","Open file"). Ensure users have permission to access the shared folder.
Can Power Query return the full hyperlink address?
Yes. You can generate a URL or file-path column in SQL or in Power Query, then use an adjacent worksheet formula such as =HYPERLINK([@FilePath],"Open") to make it clickable.
Will dynamic hyperlinks handle new rows after refresh?
They can, provided the formula column remains next to the query table and uses the current row's key or destination field. After refresh, verify that Excel has extended the calculated formula to any newly returned rows.




