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
I'm trying to find a way to pass the user selections from 2 different slicers as inputs to some to create custom python visuals. I found this answer (It is possible to read a slicer value from a pytho... - Microsoft Fabric Community) that suggests creating a new text parameter to store the user inputs.
However when I go to Modeling > New Parameter, I don't have a Text option under data type, only Whole number, Decimal number and Fixed decimal number. I've googled around some tutorials on how to do this, but none have helped. Some have a drop down menu by the New Parameter button which I don't have, and others say just select text under the Data type dropdown.
Any help with how to do this (or a simpler way to pass user selected values into the python code for a visual) would be greatly apreciated.
Solved! Go to Solution.
Thanks for the reply from 123abc , please allow me to provide another insight:
Hi, @EmiOB
Thanks for reaching out to the Microsoft fabric community forum.
Regarding the issue you raised, my solution is as follows:
You can try combining the parameter field with the SELECTEDVALUE() function. Here’s how you can do it:
Use report readers to change visuals (preview) - Power BI | Microsoft Learn
For example, my sample data includes multiple columns:
1. Create two parameter fields as you need two slicers.
2.Since directly applying the SELECTEDVALUE() function to the parameter column may cause errors, it is recommended to create a calculated column for each parameter:
3.Create a measure to clearly identify the selected column name:
selection1 = SELECTEDVALUE('Parameter2'[Column n])selection2 = SELECTEDVALUE('Parameter'[Column n1])
4. Use the two parameters and the two measures as inputs in the Python custom visual object:
5. Use the loc method to directly select the column..Here is my test Python code:
import matplotlib.pyplot as plt
# Paste or type your script code here:
dataset['Selected1'] = dataset.apply(lambda row: row.loc[row['selection1']], axis=1)
dataset['Selected2'] = dataset.apply(lambda row: row.loc[row['selection2']], axis=1)
# Create a figure and a subplot
fig, ax = plt.subplots(figsize=(8, 3)) # Set the size of the chart
# Hide the default x-axis and y-axis
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
ax.set_frame_on(False)
# Create a table, displaying only the Selected1 and Selected2 columns
table = ax.table(cellText=dataset[['Selected1', 'Selected2']].values, colLabels=['Selected1', 'Selected2'], cellLoc='center', loc='center')
# Adjust the table style
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
# Display the chart
plt.show()
6.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please follow belo community soluiton: Hope This will help you;
Solved: Pass a text parameter in report - Microsoft Fabric Community
I hope this helps!
If you found this answer helpful:
Mark it as the solution to help others find it faster.
Give it a kudo to show your appreciation!
Thank you for being an awesome community member!
I have about 90 different options, and I need the user to select 2 (probably from 2 separate slicers, to be the x and y axis of a scatter plot). This solution suggests I will manually need to put each option into something like an IF statement, which isn't really practical.
Thanks for the reply from 123abc , please allow me to provide another insight:
Hi, @EmiOB
Thanks for reaching out to the Microsoft fabric community forum.
Regarding the issue you raised, my solution is as follows:
You can try combining the parameter field with the SELECTEDVALUE() function. Here’s how you can do it:
Use report readers to change visuals (preview) - Power BI | Microsoft Learn
For example, my sample data includes multiple columns:
1. Create two parameter fields as you need two slicers.
2.Since directly applying the SELECTEDVALUE() function to the parameter column may cause errors, it is recommended to create a calculated column for each parameter:
3.Create a measure to clearly identify the selected column name:
selection1 = SELECTEDVALUE('Parameter2'[Column n])selection2 = SELECTEDVALUE('Parameter'[Column n1])
4. Use the two parameters and the two measures as inputs in the Python custom visual object:
5. Use the loc method to directly select the column..Here is my test Python code:
import matplotlib.pyplot as plt
# Paste or type your script code here:
dataset['Selected1'] = dataset.apply(lambda row: row.loc[row['selection1']], axis=1)
dataset['Selected2'] = dataset.apply(lambda row: row.loc[row['selection2']], axis=1)
# Create a figure and a subplot
fig, ax = plt.subplots(figsize=(8, 3)) # Set the size of the chart
# Hide the default x-axis and y-axis
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
ax.set_frame_on(False)
# Create a table, displaying only the Selected1 and Selected2 columns
table = ax.table(cellText=dataset[['Selected1', 'Selected2']].values, colLabels=['Selected1', 'Selected2'], cellLoc='center', loc='center')
# Adjust the table style
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
# Display the chart
plt.show()
6.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for taking the time to reply. I've seen a few places describe your method, however I don't have the drop down menu on the New parameter button:
When I click on it, this window comes up:
There doesn't seem to be any option for text/fields as I've seen in yours and others examples.
Also, is there no other way to get the value without having to type out each parameter in a DAX expression? I have about 90 options I'd like the user to select 2 of, so this would take a while (I could automate the DAX string in some python code if this is the only way).
Hi, @EmiOB
Thanks for your quick response, please check if you have the following Settings enabled:
Also, you don't need to write every option in dax, you just need to select it at creation time:
For further details, please refer to the following link:
Use report readers to change visuals (preview) - Power BI | Microsoft Learn
Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I don't have a preview features option in the options menu (I'm also missing Updates from your list too). I'm on the September 2023 version of BI if that makes any difference?
Hi, @EmiOB
Thank you for your quick reply.
As you can imagine, this is what has been updated throughout the year.It is recommended that you update your version according to your needs, here is the download link:
Download Microsoft Power BI Desktop from Official Microsoft Download Center
Here's what's updated for each version, and you can choose which version to update:
Previous monthly updates to Power BI Desktop and the Power BI service - Power BI | Microsoft Learn
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for all your help. Unfortunately, our prod is still the 2023 version, so I can't upgrade mine until that has been upgraded, without risking capatability for my other existing reports. I've accepted your solution as it may be useful for someone else.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |