Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am running a Python script in Power BI which does some calculations and creates a table 'PythonTable'. This table is then used by a report. Somewhere in the script, this can be found:
overall=pd.concat([name,lang,cert],axis=1)
res = (df_multiply_modified(overall, overall.T)).stack().reset_index(level=1)
The code is using the variable 'overall' which combines some groups like name, lang cert. I would like to add a slicer which can select for example name and lang, so the script will change to:
overall=pd.concat([name,lang],axis=1)
And hence 'PythonTable' will be updated. I could also just choose name, so the script will be:
overall=pd.concat([name],axis=1)
How can I achieve this?
Thank you
Hello, I have a simpler case, I want to pass a parameter to the Python script that serves as a value of a range, I have created the P parameter as a decimal number (it doesn't leave me integer) and linked to the query/list value I want. In the Current Value box I can't "deploy" anything, it only allows me to put a current value. The problem is that I can't update the parameter value so that it has the query/list value assigned to it.
On the other hand, within the Python script the value 71 of this script fragment should be replaced by the parameter and I imagine it should be: for i in range(71) ---> for i in range(" & P & "):
You can help me with the first point and confirm the second one. Thanks a lot!!.
If you want to pass a query parameter to python script, it is supported.
I made a simple demo for this, but it's not perfect. When switching to choose a parameter value which contains fewer or different columns, the steps below the Source step will probably report errors as they cannot find the missing columns to transform.
So I think dynamically changing the columns with parameters is probably not a good idea. It's suggested to contain all the necessary columns in the model, but select different columns for different visuals as you need in the report.
Kindly let me know if this helps.
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
How do you get to that screen?
@Anonymous It is Advanced Editor in Power Query Editor. Query overview in Power BI Desktop
If I guess correctly, your python table is a table query created by python script, right? If so, it is created first, then loaded into Power BI Desktop to create a report from. If you want to use a slicer in the report to dynamically change the columns in your python table, I'm afraid this is not supported. The slicers and filters in the report are not able to influence how a table query is created and transformed in the Query Editor.
Best Regards,
Community Support Team _ Jing Zhang
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
67 | |
57 | |
54 | |
36 | |
34 |
User | Count |
---|---|
84 | |
71 | |
55 | |
45 | |
43 |