Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

How do i create a dynamic URL in Powerbi source query

I am trying to load data from Log analytics and i am i want to create dynamic URLS for each customer when i open PBIT template file.

 

eg --> let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/WORKSPACEID/query", 

 

I want WORKSPACEID to be dynamic. I tried two methods

 

1. Reading the WORKSPACEID from text file and ( i have a per customer folder so, chosing right file is taken cared of using the parameterised path to file)

2. Using this, i created an additional query to extract only WORKSPACEID.

 

= let Source = Json.Document(Web.Contents( "https://api.loganalytics.io/v1/workspaces/"& "#LAWorkspace" &"/query",

When i use this query name in the Main query to log analytics, it throws error.

 

Expression.Error: We cannot apply operator & to types Text and List.

I also tried creating a new table with all WORKSPACE ID's and customer name mapping and tried to using ID from this table , even this fails.

"Expression.Error: We cannot apply operator & to types Text and List."

let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/" & WorkspaceID & "/query",

 

Any help would be appreciated, already spent a day , going crazy 😞

3 Replies

  • v-lid-msft's avatar
    v-lid-msft
    Community Support

    Hi Anonymous ,

     

    First of all, please create a parameter named "WORKSPACEID and format as text, then try to use the following query:

     

    let
      Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces",[RelativePath="/" & WORKSPACEID &" /query"]))
    
    in
      Source

     

     


    Best regards,

     

  • v-lid-msft's avatar
    v-lid-msft
    Community Support

    Hi Anonymous ,

     

    How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


    Best regards,

  • Once I publish the report to powerbi cloud, and then embed this to another website A, is it possible to change the parameter from front-end user side? or how can this parameter be easily changed by the website A.