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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
vika_cheng
New Member

Make Parameters in Python as the User Input in Power BI

Hi everyone,

 

I currently have a Python script designed to generate a basic report for ANOVA analysis. Within this script, I can modify parameters in Python (e.g., date range, data source, metric etc.) to extract the necessary data and perform the analysis. I am wondering if it's feasible to enable users to dynamically select these parameters within Power BI. This would ensure that the data input to Power BI is adjusted accordingly based on user preferences.

 

Best regards,

Vika

1 REPLY 1
Anonymous
Not applicable

Hi  @vika_cheng ,

 

Unfortunately, Power BI does not natively support dynamic user input for parameters within the Python script execution itself. However, there is a workaround using Power Query:

1.Create Query Parameters.

2.Invoke Python Script with Parameters:

  • Still in the Power Query editor, you can invoke a Python script by adding a new step with the Python script option.
  • In the Python code, retrieve the parameters from the Power Query environment and use them in your script. Here's an example:
    import pandas as pd
    
    # Assuming 'date_range' is a parameter from Power Query
    date_range = ... # Replace with code to get parameter from Power Query
    
    # Your Python code that uses the parameter

After you apply the changes, the Python script will run using the parameters set in Power Query.

 

Please refer to the following documents for more information.

Dynamic M query parameters in Power BI Desktop - Power BI | Microsoft Learn

Top use cases for dynamic data parameterization in Power BI - Neal Analytics

Creating Dynamic Reports with Power BI: Using Parameters and Variables (skillzcafe.com)

 

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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Solution Authors