Forum Discussion

Lars-6's avatar
Lars-6
Regular Visitor
1 year ago
Solved

Change parameter with slicer

Hi everyone, 

 

I have a parameter, that has an invoice id in it. 

 

I want to change this number with a slicer. I have made a column in a table with these invoice numbers (which I changed to type text) so that I can search in the slicer. it looks something like this:

 

but what I want now is that when you change the slicer to for example "2025033" the parameter also changes to 2025033. 

how can I make this? 

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Lars-6,

    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    A special thanks to Deku and adudani  for the quick and helpful response.

     

    To dynamically retrieve data from an API in Power BI based on an input parameter, you can create a parameter and use it in the API URL within Power Query. Start by navigating to Home -> Manage Parameters -> New Parameter in Power BI Desktop. Name the parameter (e.g., InvoiceID), choose its data type (such as Text or Number), and either define a list of values or set it to "Any value" if you want more flexibility. Next, open Transform Data to launch Power Query, and create a new query that incorporates the parameter into your API URL. For example, the M code would look like this:

    let
    InvoiceID = Parameter, // this is the parameter you've created
    Source = Json.Document(Web.Contents("https://your-api-endpoint.com/data?invoice_id=" & Text.From(InvoiceID)))
    in
    Source


    After setting this up, click Close & Apply to load the data into your Power BI model using the dynamically constructed URL.

     

    If you found this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to help others in the community.

     

    Thank you & regards,
    Prasanna Kumar

7 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Okay, I have the parameter in a api url string, so I can change the input for the api. This means that I can pull data per invoice id. Do you know how I can do this in any other way so when I change the slicer the api request url also changes.

       

      Already thanks!

       

      Lars

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Lars-6,

    Thank you for reaching out to the Microsoft Fabric Forum Community.

     

    A special thanks to Deku and adudani  for the quick and helpful response.

     

    To dynamically retrieve data from an API in Power BI based on an input parameter, you can create a parameter and use it in the API URL within Power Query. Start by navigating to Home -> Manage Parameters -> New Parameter in Power BI Desktop. Name the parameter (e.g., InvoiceID), choose its data type (such as Text or Number), and either define a list of values or set it to "Any value" if you want more flexibility. Next, open Transform Data to launch Power Query, and create a new query that incorporates the parameter into your API URL. For example, the M code would look like this:

    let
    InvoiceID = Parameter, // this is the parameter you've created
    Source = Json.Document(Web.Contents("https://your-api-endpoint.com/data?invoice_id=" & Text.From(InvoiceID)))
    in
    Source


    After setting this up, click Close & Apply to load the data into your Power BI model using the dynamically constructed URL.

     

    If you found this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to help others in the community.

     

    Thank you & regards,
    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Lars-6,

     

    Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

    If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.

     

    Best regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Lars-6,

     

    We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.

    If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution — it helps others who might face a similar issue.

     

    Warm regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Lars-6,

     

    Just a gentle reminder — has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.

    This not only closes the loop on your query but also helps others in the community solve similar issues faster.

    Thank you for your time and feedback!

     

    Best,

    Prasanna Kumar