Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I have a plot that looks at daily mean sales for different products, which I made using matplotlib. Now I want a slicer that allows for the removal of unselected lines in the python script. I have the slicer set up but it does not remove the line but does filter the data, which I thought would remove the line but it stays (likley in a default state maybe?).
Here is a code snippit for reference.
Solved! Go to Solution.
I did 'Fix' this by just realizing something about how Python and Power Bi work together.
When you use a slicer it will filter the column you are plotting. There is no need to 'define' a slicer in the python script
First let me say that its a specific way of thinking one needs to approach this combo. In my way of thinking 'you' as the programmer define the behaviour of the slicer by making a connection between the slicer and the python script. This is wrong. Power Bi, when you add a slicer, will filter the data and run the python script again with the new data filtered data frame. So for me I needed to remove some of the programmers thinking and allow Power Bi to do the thing it does best, simplify a lot of tasks.
It isn't a 'programming' solution or software solution - its a 'Aha, thats smart' light bulb monent solution.
Hi @Eiki
I don't know what line you want to remove.
Could you show an example with pictures?
Best Regards
Maggie
I don't have the file right now - but I found a solution.
For the slicer to work in the python script there needs to be a refernce to that file. So there could be an example like this
plt.plot(df['date'], df[f'Product{i}'].where(df[f'Product{i}'].isin(ProductList))
The ProductList is the list I reference in the slicer so now it works.
Thanks again - I found the solution by reading the forum here and Trial and Error
I did 'Fix' this by just realizing something about how Python and Power Bi work together.
When you use a slicer it will filter the column you are plotting. There is no need to 'define' a slicer in the python script
First let me say that its a specific way of thinking one needs to approach this combo. In my way of thinking 'you' as the programmer define the behaviour of the slicer by making a connection between the slicer and the python script. This is wrong. Power Bi, when you add a slicer, will filter the data and run the python script again with the new data filtered data frame. So for me I needed to remove some of the programmers thinking and allow Power Bi to do the thing it does best, simplify a lot of tasks.
It isn't a 'programming' solution or software solution - its a 'Aha, thats smart' light bulb monent solution.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 62 | |
| 54 | |
| 40 | |
| 17 | |
| 14 |
| User | Count |
|---|---|
| 96 | |
| 83 | |
| 36 | |
| 30 | |
| 25 |