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
This is a basic python headmap script visual in Power BI.
I am looking to apply a filter to this python script code bellow.
How can be this be filter by slicer(dimension) in this correlation Heatmap code? Below is the code I have written.
------
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# dataset = pandas.DataFrame(A_DENO, A_NUM, _Acceptable,_S_ASIS,_A_ASIS, _Offered,_Region)
# dataset = dataset.drop_duplicates()
# Paste or type your script code here:
import pandas as pd # for data analysis
import matplotlib.pyplot as plt
import seaborn as sns
# Compute the correlation matrix
#filter by Region
# HERE NEED TO MAKE DATASET3.['REGION']
###dataset2= dataset.loc[dataset.Region =='North America' ]
corr = dataset2.corr()
##plt.figure(figsize=(17,17))
sns.heatmap(corr,cmap='coolwarm', annot = True, fmt='.5g',linewidth =1.9)
#plt.title("Correlation HeatMap", fontsize = 16)
plt.xlabel("Features", fontsize = 10)
plt.ylabel("Features", fontsize = 10)
plt.show()------
The dataset contains several columns.
But I took the picture for those I am interest to work in this python script.
_S_ASIS=
DIVIDE( SUM('Cad_KPI'[_Acceptable]), SUM('Cad_KPI'[_Offered]))*100
_A_ASIS
=DIVIDE(DIVIDE( SUM('Cad_KPI'[_A_NUM]), SUM('Cad_KPI'[_A_DENO])), 60)Sample data in this image.
Solved! Go to Solution.
Hi @perezco,
I think your heat map needs at least two lines of data.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Hi @perezco ,
Power BI replots the Python visual, whenever a data change occurs. (filtering)
The Python visual always only receives the filtered data.
https://docs.microsoft.com/en-us/power-bi/desktop-python-visuals
Regards,
Marcus
Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
right, @mwegener .... yes I can used the filters section for the Vizulation from the left but I need is to use slicer filter.
example for Bar chart code:
Hi @perezco ,
could you share your sample pbix?
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Hi @perezco,
I think your heat map needs at least two lines of data.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
yes, I am aware this demo file brings few records.. But I see that work fine with the filters slicers.
thanks
Hi @perezco ,
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 44 | |
| 42 | |
| 21 | |
| 17 |
| User | Count |
|---|---|
| 183 | |
| 114 | |
| 93 | |
| 62 | |
| 45 |