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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I have a dataframe in PowerBI and I want to conduct Market Basket Analysis(Association Rules) on it, with a Python Script and then present the results through PowerBI.
However, some of the input variables should be defined from the user (e.g. Customer Type, Time Period etc). These input parameters, would be the ones that would initialize the python script that would run in the background on the fly.
The results woud be then presented in PowerBI, with a table,graph etc.
Sounds like this is something possible?
Solved! Go to Solution.
the input variables should be defined from the user (e.g. Customer Type, Time Period etc) :
this info needs to be in the dataset. In other words, you can create slicers in Power BI for user input, such as Customer Type, Time Period. These slicers can be linked to your data so that it's filtered based on the user's choice.
It wouldn't let me share either a .pbix file or upload a .csv file, so I copied and pasted the information that is included in the dataframe.
| ACCOUNT_ID | BEGINTIME | Time_Period | GAME_GROUP_ID | NEW_OLD_GAME |
| 112541623 | 11/8/23 | 19 | 1928 | Old Game |
| 115543802 | 17/8/23 | 13 | 1928 | Old Game |
| 113374408 | 18/8/23 | 12 | 1928 | Old Game |
| 115160020 | 18/8/23 | 12 | 1928 | Old Game |
| 113912079 | 19/8/23 | 11 | 1928 | Old Game |
| 115469783 | 20/8/23 | 10 | 1928 | Old Game |
| 109318613 | 21/8/23 | 9 | 1928 | Old Game |
| 109498325 | 21/8/23 | 9 | 1928 | Old Game |
| 111936453 | 23/8/23 | 7 | 1928 | Old Game |
| 115831558 | 23/8/23 | 7 | 1928 | Old Game |
| 110365656 | 24/8/23 | 6 | 1928 | Old Game |
| 109498325 | 25/8/23 | 5 | 1928 | Old Game |
| 112022648 | 5/6/23 | 86 | 1366 | Old Game |
| 70331 | 28/6/23 | 63 | 1366 | Old Game |
| 112414583 | 11/7/23 | 50 | 1366 | Old Game |
| 110457715 | 13/8/23 | 17 | 1366 | Old Game |
| 110216708 | 7/8/23 | 23 | 7677 | New Game |
| 109935741 | 24/7/23 | 37 | 3500 | Old Game |
| 116582638 | 17/7/23 | 44 | 6386 | Old Game |
| 110261719 | 19/6/23 | 72 | 7257 | Old Game |
the input variables should be defined from the user (e.g. Customer Type, Time Period etc) :
this info needs to be in the dataset. In other words, you can create slicers in Power BI for user input, such as Customer Type, Time Period. These slicers can be linked to your data so that it's filtered based on the user's choice.
Ok. Let's stay for example at the time period that exists in the dataframe.
I have a slicer in powerbi from which user can make a selection.
The question is, how I can return this value as a parameter to the python script and make the script run with this variable?
Check this : https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-python-in-query-editor
The input dataframe is similar to below.
What I want is to run the market basket analysis with/without New Games because in many cases they skew my results. Or also to be able to include/exclude low value customers.
These parameters should be inserted as input from the user, passed as parameter to python script in the background in order to run the market basket analysis algorithm and then return the results.
Can you please provide your dataframe as text not a picture ? or a model in a pbix file ?
Can you please share your pbix ? or datafarame?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 46 |