Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Power BI Query Parameters in the UI Report

Often, we have to link to website data via API, and we use query parameters for parts of its API.

for example, the parameter 'location' is being used in part of its API as below:

https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{location}/2022-05-03/2022-05-03?unitGroup=metric&include=days&key=*****&contentType=csv

How are we able to bring this parameter 'location' to the UI report itself, such that user has a list of locations to choose from?

 

  • Hi Anonymous,

     

    Use & to combine these strings and

    First, you need create a parameter named location or something you like and use this M code to do it:

    let
        yourkey = "PVACBQ6LTCVBR9NBF529V3H8V",
        url = "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/"& location &"?key="& yourkey,
        data = Json.Document( Web.Contents(url))    
    in
        data

    Reault:

     

    Best Regards

    Community Support Team _ chenwu zhu

     

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

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the link and prompt reply, I will give it a try and let you know 🙂

      I am not sure if that works for API, hopefully it works.

      • SpartaBI's avatar
        SpartaBI
        Community Champion

        Anonymous  I'm not sure also ğŸ˜ƒ

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

    Hi Anonymous,

     

    Use & to combine these strings and

    First, you need create a parameter named location or something you like and use this M code to do it:

    let
        yourkey = "PVACBQ6LTCVBR9NBF529V3H8V",
        url = "https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/"& location &"?key="& yourkey,
        data = Json.Document( Web.Contents(url))    
    in
        data

    Reault:

     

    Best Regards

    Community Support Team _ chenwu zhu

     

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      with the code in M code, I have below error: