Forum Discussion
Can't create a text parameter
- Anonymous1 year ago
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!
- EmiOB1 year agoRegular Visitor
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.
- Anonymous1 year agoNot applicable
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.
- EmiOB1 year agoRegular Visitor
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).