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
anedesquerra
New Member

Get selected values in powerBI listbox from Python visual script

I'm creating a Python visual inside a PowerBI Desktop dashboard, and I need to filter out a dataset I read from a local folder based on selected values of slicers. So far, I can get all values from every slicer, but what I really need is to get only the selected ones. Does someone know how can I get a list of those selected values inside using Python code or send me the link of a post with the same situation if it applies?

 

Thanks in advance.

1 ACCEPTED SOLUTION
anedesquerra
New Member

Hello, community! Thanks anyway for your reviews!

Finally, after several trial-error codes, I found one solution that works the way I wanted.

Here goes the one-line code in Python if someone needs it in the future.

 

My data field is named steel_fam_desc, so you just need to change your current field name in your code. 

steel_fam_desc = list(set(dataset.steel_fam_desc))
 
Cheers up community!

View solution in original post

1 REPLY 1
anedesquerra
New Member

Hello, community! Thanks anyway for your reviews!

Finally, after several trial-error codes, I found one solution that works the way I wanted.

Here goes the one-line code in Python if someone needs it in the future.

 

My data field is named steel_fam_desc, so you just need to change your current field name in your code. 

steel_fam_desc = list(set(dataset.steel_fam_desc))
 
Cheers up community!

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.