Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi! And welcome to my issue...would appreciate any help you might be able to provide. 🙂 This is very strange and I've been unable to figure this out.
Importing data from an Excel file, and that file has a field or two with URLs to Power BI reports that could be one of the following:
The problem is with the URLs applied as formatting.
The intention is to determine which values are a complete URL in the form of "https://..." and keep them, otherwise change the value to null. This is the relevant M code where I test if the text value starts with "https://"
#"Replaced Non-Links" = Table.ReplaceValue(#"Reordered Columns", each [ Helpful Report Links], each
if Text.StartsWith([#" Helpful Report Links"], "https://") = true then [#" Helpful Report Links"] else
null,
Replacer.ReplaceText,{" Helpful Report Links"}),
#"Added Custom" = Table.AddColumn(#"Replaced Non-Links", "Checking", each Text.StartsWith([#" Helpful Report Links"], "https://"), Logical.Type),
#"Reordered Columns1" = Table.ReorderColumns(#"Added Custom",{"Report Number", "Project Track ", "PBI Team", "Report Developer Name", "Scope", "Business Process/ Specific Area", "Business Owner (SME)", "Report Type", "Report Name/ Use Case", "Report Description/ Intent", " Helpful Report Links", "Checking", " General Priority", "Report T-Shirt Size", "Build & Testing Notes ", "Report Progress Status", "Report Health Status", "Teams Responsible for Dependencies", "Team Responsible for Block or Delay", "DnA Deliverable Name(s)", "DnA Delivery Date", "DnA Handoff Date ", "Target Start ", "Target Completion", "Actual Start", "Actual Completion", "Final Reporting Deliverable(s)", "Technical Documentation", "Training Material"})
in
#"Reordered Columns1"
The last two steps are for testing my logic and showing the results next to where the transformation is applied. Here's the results
The test of Text.StartsWith() is correctly determining whether text value starts with "https://" but it is not converting the highlighted values to null. I've seen posts where Power Query cannot see any formatting, etc. from the Excel file and can only work with the values shown. Not understanding why this isn't working...
Thanks for reading this 🙂
Solved! Go to Solution.
Hi @littlemojopuppy Try use table.transformColumns :
ReplacedNonLinks = Table.TransformColumns(#"Changed Type", {{"Helpful Report Links", each if Text.StartsWith(_, "https://") then _ else null, type nullable text}})
Where #"Changed Type" is the previous steps.
Output:
Hope this helps!!
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz
First of all, we should reach a consensus that power query can only read the values in the Excel file, and cannot obtain the links in the values.
Next, let's discuss why the result of the formula is wrong.
You used the Replacer.ReplaceText function, which cannot accept null as a parameter. If used, it will only report an error or do nothing. A more detailed explanation is:
There are many solutions. The simplest one is to replace Replacer.ReplaceText with Replacer.ReplaceValue function. Another method is to use the following solution:
let
Source = Table.FromColumns(List.Repeat({{null, "", "abc", "xabc"}}, 2), {"A", "B"}),
Replace = Table.ReplaceValue(
Source, null, null,
(txt, old, new) => if Text.StartsWith(txt, "ab") = true then txt else null,
{"B"}
)
in
Replace
Hi @littlemojopuppy Try use table.transformColumns :
ReplacedNonLinks = Table.TransformColumns(#"Changed Type", {{"Helpful Report Links", each if Text.StartsWith(_, "https://") then _ else null, type nullable text}})
Where #"Changed Type" is the previous steps.
Output:
Hope this helps!!
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz
Hi @shafiz_p had to make one small change to check if value was null before TextStarts() but otherwise worked perfectly. Thank you! 🙂
Hi @littlemojopuppy
Can you pls provide a sampl excelsheet/data with out any sensitive information. Thanks
please provide a sample Excel file and indicate the expected outcome.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
10 | |
8 | |
6 | |
6 | |
6 |