Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
manasengineer
Frequent Visitor

Dax code to combine bookmarks

Hi y'all,

I have a button, which when a selection is chosen from the primary slicer, and then the button is pressed on, takes me to a URL link attached, now, I want to write a dax for the button such that, Power Bi checks if the URL link actually exists or not, if it exists, it takes me to the link, if not, then my bookmark (which is a pop-up window) gets activated and shows up.

I would appreciate any tips and suggestions with this. 

 

Thank you so much. 

Sincerely,

ME

2 REPLIES 2
Anonymous
Not applicable

Hi @manasengineer ,

 

We can't use DAX to validate our URLS. But we can make the URL validation in Power Query.

Refer to

Solved: URL validation - Microsoft Fabric Community

You can use the Web.Contents function in Power Query to get the status code of a URL. If the status code is 200, then the URL exists, and you can navigate to it. Otherwise, you can show the bookmark. Here is a sample DAX code that uses the Web.Contents function to get the status code of a URL:

let
    url = "https://www.example.com",
    response = Web.Contents(url, [RelativePath="", Headers=[#"User-Agent"="Mozilla/5.0"]]),
    status = Value.Metadata(response)[Response.Status]
in
    status

In this example, we use the Web.Contents function to get the status code for the URL "https://www.example.com". Note that we also set a User-Agent header so that the web server knows that we are accessing the URL using the Mozilla Firefox browser. Finally, we use the Value.Metadata function to get the metadata of the response, and then use the Response.Status key to get the status code.

Note that if your URL requires authentication, you will need to provide authentication credentials. You can use the Options parameter of the Web.Contents function to provide authentication credentials.

 

          

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Hi @Anonymous,

 

Thank you so much for responding with a prompt method and explaining in detail, so I just wanted to further ask, if its ok, the URL is a dynamic URL in DAX,

 

eg: URL = "https://example.com/"&[Selected Option from Slicer Name]&".extension" 

 

Based of on this, I went to Power Query to my data source and inputted the above mentioned DAX into Custom Column option, when I hit enter, the following message pops-up: 

 

Formula.Firewall: Query 'All Info' (step 'Added Custom') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. 

 

(All Info is my table name), I tried researching a solution for the above and stumbled upon this link:

https://excelguru.ca/power-query-errors-please-rebuild-this-data-combination/

But I was not able to understand it properly, therefore, do you think I am missing a step or inputting the DAX at the wrong section, how do I overcome this error. 

Also, once I validate a URL through all this, how can I incorporate bookmarks in DAX, 

i.e., if status=200, open this link. else _____?

 

Thank you so much again Stephen for your help and responses. 

 

Sincerely,

ME

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.