Forum Discussion
Need help for converting file paths
I Have List fo field paths for each document id Like in the screenshot. My requirment is when i click on the file path the pdf document should be load in the browser. I tried to change data category as WEB Url but it is working. Please guide me to acheive this.
- Anonymous2 years ago
Hi Srinivas_BI
After testing, if your file is a local file, Power BI Desktop provides a link with "file"///your file path", but the link can no longer be opened on Desktop, if you want to open it on the website, you can only copy the link and paste it in the web page.You can refer to the following link.
Solved: Can not hyperlink to file in computer - Microsoft Fabric Community
So, the best way is that you can consider putting these files on your website, for example you can upload the files to SharePoint and then copy the web page link of the file, it can open in Desktop as web url.
Upload files and folders to a library - Microsoft Support
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- grazitti_sapnaSuper User
Hi Srinivas_BI
1. Use Power Query to Transform the File Paths:
- You can transform the file paths in Power Query to prepend https:// and convert the backslashes (\) to forward slashes (/).
Steps:
- Go to Transform Data to open Power Query Editor.
- Select the column with the file paths.
- Use the Add Column tab to create a Custom Column with the following formula:
New Path = "https://" & Text.Replace([FilePath], "\", "/") - This will create a new column with the file paths correctly formatted as URLs.
2. Set the Data Category:
- After transforming the file paths in Power Query and applying the changes, go back to your report view.
- Select the new column name New Path in the Fields pane.
- Go to the Modeling tab and set the Data Category to Web URL.
3.Display the Links in a Table Visual:
- Add the newly created column to your table visual. This should now display clickable URLs that open the PDFs in a browser.
The difference between / and \ in URLs is that / is a valid character used to separate directory paths, while \ is generally not allowed and can cause errors.
/ :
- Purpose: Separates directory paths in URLs.
- Usage: Common and widely accepted in all web browsers and servers.
- Example: https://example.com/folder/subfolder/file.html
\:
- Purpose: Primarily used as a backslash in programming languages.
- Usage: Not commonly used in URLs. If used, it might be interpreted as an escape character or cause errors.
- Example: https://example.com\folder\subfolder\file.html (not recommended)
Thank You
- AnonymousNot applicable
Hi Srinivas_BI
After testing, if your file is a local file, Power BI Desktop provides a link with "file"///your file path", but the link can no longer be opened on Desktop, if you want to open it on the website, you can only copy the link and paste it in the web page.You can refer to the following link.
Solved: Can not hyperlink to file in computer - Microsoft Fabric Community
So, the best way is that you can consider putting these files on your website, for example you can upload the files to SharePoint and then copy the web page link of the file, it can open in Desktop as web url.
Upload files and folders to a library - Microsoft Support
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.