Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Using parameters to get data from dynamic url

Hello,

 

I have not been able to find a solution to my problem even tho there are similar solved problems in this forum.

What I am trying to do is use parameters (from cell*s or table*s) in an url.

 

To define the parameters I tried two different solutions.

The first one was to write the value in a table and get the value via a Query.

It looks like this:

 

let
    Source = Excel.CurrentWorkbook(){[Name="TestenParams"]}[Content],
    TestParam1 = Record.Field(Source{0},"Start")
in
    TestParam1

 

 

The other one was defined by using the built-in option of the Power Query Editor.

 

I would prefer to use the first variant but for testing purposes I tried both.

 

The next step was trying to replace a part of the url with the parameter.

A simplified example of the important part of the Query would look like this:

 

let
    TestParam1 = Start,
    Source = Json.Document(Web.Contents("https://someurl.com/somecategory/64dfg8d484-4fsd4-fwewtg1w8/records?fromHere="&TestParam1&"&toHere=1525426100", [Headers=[Accept="*/*", #"Content-Type"="application/json"]])),
    #"Converted to Table" = Record.ToTable(Source),

 

 

For some reason I have not been able to create a working url using parameters.

Most of the time I get the "Expression.Error: We cannot apply operator & to types Text and Number" error.

Why am I not able to use parameters this way?

 

Thank you.

LPLA

  • Source = Json.Document(Web.Contents("https://someurl.com/somecategory/64dfg8d484-4fsd4-fwewtg1w8/records?fromHere="& Text.From(TestParam1) &"&toHere=1525426100", [Headers=[Accept="*/*", #"Content-Type"="application/json"]]))

2 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion
    Source = Json.Document(Web.Contents("https://someurl.com/somecategory/64dfg8d484-4fsd4-fwewtg1w8/records?fromHere="& Text.From(TestParam1) &"&toHere=1525426100", [Headers=[Accept="*/*", #"Content-Type"="application/json"]]))
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks a lot. I was searching for some kind of conversion but couldn't find it.
      Unfortunately this created a new issue.

      After using the parameter I get the following error:

      Formula.Firewall: Query 'Testen' (step 'Expanded Value.chargebacks') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.

      I already got this error when trying something very similar, but I could'nt find a way to solve it.
      The solution https://community.powerbi.com/t5/Desktop/Formula-Firewall-Query-references-other-queries-so-it-may-not/m-p/18619 seems to be correct but I can find the "Privacy" tab when going to File -> Options -> General -> Privacy Settings... but there isn't really anything for me to turn off or on.

      I'll try to get this fixed because I'm trying to automate some of the time consuming steps in my workflow.
      Still me original problem was solved by CNENFRNL so I will tag it as the solution.

      Thank you.
      LPLA