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
NickFournogerak
Frequent Visitor

Connection PowerBI with Python Script for Association Rules

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?

 

1 ACCEPTED 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.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

7 REPLIES 7
NickFournogerak
Frequent Visitor

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_IDBEGINTIMETime_PeriodGAME_GROUP_IDNEW_OLD_GAME
11254162311/8/23191928Old Game
11554380217/8/23131928Old Game
11337440818/8/23121928Old Game
11516002018/8/23121928Old Game
11391207919/8/23111928Old Game
11546978320/8/23101928Old Game
10931861321/8/2391928Old Game
10949832521/8/2391928Old Game
11193645323/8/2371928Old Game
11583155823/8/2371928Old Game
11036565624/8/2361928Old Game
10949832525/8/2351928Old Game
1120226485/6/23861366Old Game
7033128/6/23631366Old Game
11241458311/7/23501366Old Game
11045771513/8/23171366Old Game
1102167087/8/23237677New Game
10993574124/7/23373500Old Game
11658263817/7/23446386Old Game
11026171919/6/23727257Old 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.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

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


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
NickFournogerak
Frequent Visitor

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.

Screenshot 2023-10-10 at 4.32.46 PM.png

Can you please provide your dataframe as text not a picture ? or a model in a pbix file ?


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
AmiraBedh
Resident Rockstar
Resident Rockstar

Can you please share your pbix ? or datafarame?


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

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.