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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RFJammer
Frequent Visitor

How do I use a slicer value to change a query?

Hopefully I'm going to explain this correctly. 

 

I've been playing around with the REST API from Pexels to load images into a Power BI dashboard. I've got that bit working by doing the following 

 

let
    Source = Json.Document(Web.Contents(Text.Combine({"https://api.pexels.com/v1/photos/", "2014421"}), [Headers=[Authorization="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]])),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded src" = Table.ExpandRecordColumn(#"Converted to Table", "src", {"original", "large2x", "large", "medium", "small", "portrait", "landscape", "tiny"}, {"src.original", "src.large2x", "src.large", "src.medium", "src.small", "src.portrait", "src.landscape", "src.tiny"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded src",{{"id", Int64.Type}, {"width", Int64.Type}, {"height", Int64.Type}, {"url", type text}, {"photographer", type text}, {"photographer_url", type text}, {"photographer_id", Int64.Type}, {"avg_color", type text}, {"src.original", type text}, {"src.large2x", type text}, {"src.large", type text}, {"src.medium", type text}, {"src.small", type text}, {"src.portrait", type text}, {"src.landscape", type text}, {"src.tiny", type text}, {"liked", type logical}, {"alt", type text}})
in
    #"Changed Type"

 

What I want to do is to have a slicer on my dashboard, which allows the user to select a value from 0 to 5 and this value is added to the API call above (specifically where you can see 2014421).

 

How do I take the slicer value and use it in the above query? Can this even be done? I thought a parameter might be the way to go, but I'm a bit confused TBH so I'd be grateful for any kind soul that can guide me. 

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @RFJammer 

This can't be done in Power BI.

Slicers operate on the report layer, after the data is loaded. Your API call happens in Power Query, which runs before the data reaches the model. There's no connection between a slicer and the query logic that generates or loads the data. You can't use a slicer to change the value in a Web.Contents call.

If you want to change the number in the API URL (like "2014421") based on a user selection, the only option is to use a parameter in Power Query. That parameter must be changed manually in Power BI Desktop or via the dataset settings in the Power BI Service before refresh. It’s not interactive and it doesn’t respond to slicer selections.

Dynamic M Parameters allow some user interaction with queries, but only in DirectQuery mode and only with supported sources like SQL Server – not with web APIs.

This limitation is by design and applies to all import-based queries and API calls in Power BI.

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

danextian
Super User
Super User

Hi @RFJammer 

As @Ritaf1983 already pointed out, this can't be done with slicers. Changes made in the Query Editor impact the data model, but not the other way around. Instead, consider using a query parameter or loading a table into the model that contains all the possible options, allowing users to make selections from there.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
v-achippa
Community Support
Community Support

Hi @RFJammer,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @danextian and @Ritaf1983 for the prompt response.

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the super user resolved your issue? or let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @RFJammer,

 

We wanted to kindly follow up to check if the solution provided by the super user resolved your issue.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

Hi @RFJammer,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the super user resolved your issue.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

danextian
Super User
Super User

Hi @RFJammer 

As @Ritaf1983 already pointed out, this can't be done with slicers. Changes made in the Query Editor impact the data model, but not the other way around. Instead, consider using a query parameter or loading a table into the model that contains all the possible options, allowing users to make selections from there.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ritaf1983
Super User
Super User

Hi @RFJammer 

This can't be done in Power BI.

Slicers operate on the report layer, after the data is loaded. Your API call happens in Power Query, which runs before the data reaches the model. There's no connection between a slicer and the query logic that generates or loads the data. You can't use a slicer to change the value in a Web.Contents call.

If you want to change the number in the API URL (like "2014421") based on a user selection, the only option is to use a parameter in Power Query. That parameter must be changed manually in Power BI Desktop or via the dataset settings in the Power BI Service before refresh. It’s not interactive and it doesn’t respond to slicer selections.

Dynamic M Parameters allow some user interaction with queries, but only in DirectQuery mode and only with supported sources like SQL Server – not with web APIs.

This limitation is by design and applies to all import-based queries and API calls in Power BI.

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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