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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
rjobaan
Frequent Visitor

Dynamic display names of parameter fields

I created a parameter field to show On Y-axes of a graph:

 

Y-Axis = {
    ("Gross", NAMEOF('FCT_Actual'[_REF Actual - Quantity]), 0),
    ("Budget", NAMEOF('FCT_Budget'[Budget]), 1)
}
 
The measure _REF Actual - Quantity is showing one measure based on a slicer (Gross, Nett)
_REF Actual - Quantity =
 IF (
     HASONEVALUE(Switch_Gross_Nett[Gross Nett]),
     SWITCH(
         VALUES(Switch_Gross_Nett[Gross Nett]),
         "Gross", [_REF Gross Quantity],
         "Nett", [_REF Nett Quantity]
     )
 )
 
The measure works fine
But now If I add the parameter field into graph its showing "Gross"  as display name even when Nett is selected
 
So I thought let add some code to the parameter field to make the name dynamic
 
I only changed the first part
(if(SELECTEDVALUE(Switch_Gross_Nett[Gross Nett])="Gross","Gross","Nett")", NAMEOF('FCT_Actual'[_REF Actual - Quantity]), 0),
 
But its not working. I know an "If-statemnet" works so probably the selectedvalue does not work.
 
Any one any idea how to solve this?
 
4 REPLIES 4
oduc78
Helper I
Helper I

Hello, I've got a similar issue but I haven't been able to find a solution. I created a new post: SELECTEDVALUE doesn't work to add a dynamic header to Field Parameters. Maybe comparing similar problems can help us solve them, let me know.

Olivier.

amitchandak
Super User
Super User

@rjobaan , I used code to show selected value in this blog

https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...

 

What is selected = maxx(filter(‘Axis Slicer’, ‘Axis Slicer’[Axis Slicer Order]= SELECTEDVALUE(‘Axis Slicer’[Axis Slicer Order])),’Axis Slicer’[Axis Slicer])
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I tried that, but it does not work

 

i changed (if(SELECTEDVALUE(Switch_Gross_Nett[Gross Nett])="Gross","Gross","Nett")", NAMEOF('FCT_Actual'[_REF Actual - Quantity]), 0),

into

 (if(maxx(filter(Switch_Gross_Nett, Switch_Gross_Nett[Gross Nett]= SELECTEDVALUE(Switch_Gross_Nett[Gross Nett])),Switch_Gross_Nett[Gross Nett])="Gross","Gross","Nett"), NAMEOF('FCT_Actual'[_REF Actual - Quantity], 0)
 
it keeps showing "Nett" even if I change to "Gross"

Hi @rjobaan,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.