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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
lg01
Helper I
Helper I

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

v-tianyich-msft
Community Support
Community Support

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
v-tianyich-msft
Community Support
Community Support

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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.