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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
torsten_FO
Helper I
Helper I

Dynamic Query with function value

Hi all,

in the past we have used a Query to a web.content. This query gets a value from a funktion (dynamic Start Date). This worked well until a few weeks ago. Here the Query:

 

= Json.Document(Web.Contents("http://www.myexample.com?P_WERK=[{'SIGN':'I','OPTION':'EQ', 'LOW':'CWMA'}]&P_DAT=[{'SIGN':'I','OPTION':'BT', 'LOW':'" & fktGetStartDate(10) & "','HIGH':'20211201'}]"))

 


Currently this is not possible (MS Documentation - dynamic data sources ).

How can I use a dynamic Date calculation in my Query?

 

Kind Regards,

Torsten 

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. First of all, not all the scenarios of dynamic sources can be solved. Now, let's give it shot with this one. The most important thing with web content is the way the URL is built. We need to explain the engine that the source is only the first part of the URL in order to explain that all the requests are from the same source. Otherwise it thinks that each request is a different one and can't solve it.

Because of that you can use RelativePath and Query arguments to help you build the whole URL. Please check this example from the best, Chris Webb: https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-i...

It explains how to cut your URL and set the RelativePath and the Query for the arguments (Values after ? in links).

Once you change that, you will see if the dynamic query can be refreshed in Power Bi checking the data source settings. It should only have one item with the main URL.

I hope that helps,


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

Happy to help!

LaDataWeb Blog

View solution in original post

1 REPLY 1
ibarrau
Super User
Super User

Hi. First of all, not all the scenarios of dynamic sources can be solved. Now, let's give it shot with this one. The most important thing with web content is the way the URL is built. We need to explain the engine that the source is only the first part of the URL in order to explain that all the requests are from the same source. Otherwise it thinks that each request is a different one and can't solve it.

Because of that you can use RelativePath and Query arguments to help you build the whole URL. Please check this example from the best, Chris Webb: https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-i...

It explains how to cut your URL and set the RelativePath and the Query for the arguments (Values after ? in links).

Once you change that, you will see if the dynamic query can be refreshed in Power Bi checking the data source settings. It should only have one item with the main URL.

I hope that helps,


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

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors