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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AldoOlmos239
Regular Visitor

It is possible to read a slicer value from a python script?

Hi there everyone!
I want to know if it is possible to read the selected value of a slicer in a Python Script.

Right now everytime I want to retrieve some data according the sales of "x" or "y" product category I need to change manually that value in a variable to search trought a data set.

I have been searching but havent found anything useful. Hope that you can help me!


1 REPLY 1
Anonymous
Not applicable

Hi @AldoOlmos239 ,

 

  1. Create a parameter in Power BI that will hold the value of the slicer. You can do this by going to the “Modeling” tab and clicking on “New Parameter”. Give the parameter a name and set the data type to “Text”.
  2. Add a slicer to your report that is connected to the column you want to filter on.
  3. In your Python script, you can reference the parameter you created in step 1 using the library.
report = Report("https://app.powerbi.com/reportEmbed?reportId=12345")
parameter = report.get_parameters_by_name("Parameter1")[0]
selected_value = parameter.current_value

You can refer to the following post that may be helpful to you:

Slicers as input for Python script - Microsoft Fabric Community

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors