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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
lg01
Advocate II
Advocate II

Get values selected in slicers from Python

I have a couple of slicers in my report that are built from columns in unrelated tables. I want to get the values selected in those two slicers from my Python script and execute a calculation based on these selections. How can I get the values of my slicers in my Python script? 

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Add these columns to the values well of your Python visual. They will then be part of the dataframe.

View solution in original post

Anonymous
Not applicable

Hi @lg01 ,

 

You can use DAX functions such as SELECTEDVALUE or VALUES to capture selected values. For example:

 

SelectedValue = SELECTEDVALUE(Table1[Column1])
Values = Values(Table2[Column2])

import pandas as pd
import matplotlib.pyplot as plt


df = dataset


selected_value1 = df['SelectedValue'].iloc
selected_value2 = df['Values'].iloc


result = selected_value1 + selected_value2  


print(result)

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @lg01 ,

 

You can use DAX functions such as SELECTEDVALUE or VALUES to capture selected values. For example:

 

SelectedValue = SELECTEDVALUE(Table1[Column1])
Values = Values(Table2[Column2])

import pandas as pd
import matplotlib.pyplot as plt


df = dataset


selected_value1 = df['SelectedValue'].iloc
selected_value2 = df['Values'].iloc


result = selected_value1 + selected_value2  


print(result)

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Add these columns to the values well of your Python visual. They will then be part of the dataframe.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.