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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
elria
Helper II
Helper II

Pass parameter in python script with a slicer

Hi all,

I am running a python script on a dataset fetched from SQL db connection in power bi. I am able to return a dataframe/table and visualize it but I would like to give the ability to user to define the results based on visual slicers in the report. The slicer selection should be input for python function.

I have seen that there is a possibility to create parameter but i would like to connect this parameter with a slicer in the GUI.

Do you maybe have  a solution for this?

 

Many thanks in advance!

Elria

 

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @elria 

 

I assume that you want to use query paramters with python scripts to get the corresponding result. I'd like to suggest your refer the following links to see if it helps.

Deep Dive into Query Parameters and Power BI Templates 

Power BI Desktop Query Parameters 

 

Best Regards

Allan

 

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

 

amitchandak
Super User
Super User

@elria , is this what you are looking for

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-visuals

 

Age and weight are passed to python

Hi  @amitchandak,

 

Not really. I have a dataset which i fetch in power bi from the database and I use it as input for my python script. The script performs calculations (lets say for simplifying Input 1 * Input 2) when model= x , Input1 + Input 2 when model=y etc.. and the user shoudl be able to select one model at a time with a slicer...Country and and Type also are slicers and filters for teh inputdataframe. The poblemis that the script return a second table with different output and i can't create relationships in modeling eg with country,model etc. Thus I need to give these parameters already in my input dataset.

COUNTRYTYPE

MODEL

INPUT 1 INPUT 2

A

1X101
B2Y202
C3Z303
D4W404
 
Any idea?
 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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