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!View all the Fabric Data Days sessions on demand. View schedule
Hi,
I've got a measure added to a line chart wrapped in an IF that looks to a disconnected table to see if it's toggled ON, and if not it returns blank for the measure:
IF(
Is there any way to get rid of this from the legend? I thought maybe something clever with field parameters but I can't work it out. I would rather avoid using bookmarks and (because I use implicit measure) calculation groups.
Thanks
Solved! Go to Solution.
for that follow the following steps
create a toggle table
Toggle = DATATABLE(
"Field", STRING,
{
{"On"},
{"Off"}
}
)
create a metrics parameter table
Metric Parameter =
{
("Sum Revenue", NAMEOF('Sales'[Revenue]), 0),
("Average Revenue", NAMEOF('Sales'[Revenue]), 1),
("Predicted Revenue", NAMEOF('Sales'[Predicted Revenue]), 2)
}
create a measure
Dynamic Metric =
VAR SelectedMetric = SELECTEDVALUE('Metric Parameter'[Value1])
VAR ToggleState = SELECTEDVALUE('Toggle'[Field])
RETURN
SWITCH(
TRUE(),
SelectedMetric = "Sum Revenue", SUM('Sales'[Revenue]),
SelectedMetric = "Average Revenue" && ToggleState = "On", AVERAGE('Sales'[Revenue]),
SelectedMetric = "Predicted Revenue" && ToggleState = "On", SUM('Sales'[Predicted Revenue]),
BLANK()
)
and use the values in the line chart, so now when you select ON you can see 3 legend values , when you select off it will only show 1 legend value
Hi @chris1579 ,
Has your issue been resolved?If the response provided by @kushanNa (Thank you for the answer) addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.
If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.
Thank you for your understanding!
Hi @chris1579
you need something like this ?
this how i achived this
create a slicer table
CalcType = DATATABLE(
"Metric", STRING,
{
{"Sum"},
{"Average"}
}
)create a mesure
Dynamic Revenue =
VAR SelectedCalc = SELECTEDVALUE('CalcType'[Metric])
RETURN
SWITCH(
SelectedCalc,
"Sum", SUM('Sales'[Revenue]),
"Average", AVERAGE('Sales'[Revenue]),
BLANK()
)include these values in the line chart and slicer
Thanks- how would this work if I want to have a slicer that only denotes (say) ON/OFF for the one measure? I don't need to be able to swap out the other fields in the visual.
In other words for the Switch I'd need it to return 2 fields for OFF and 3 for ON, instead of how it is in your example with one field per option.
for that follow the following steps
create a toggle table
Toggle = DATATABLE(
"Field", STRING,
{
{"On"},
{"Off"}
}
)
create a metrics parameter table
Metric Parameter =
{
("Sum Revenue", NAMEOF('Sales'[Revenue]), 0),
("Average Revenue", NAMEOF('Sales'[Revenue]), 1),
("Predicted Revenue", NAMEOF('Sales'[Predicted Revenue]), 2)
}
create a measure
Dynamic Metric =
VAR SelectedMetric = SELECTEDVALUE('Metric Parameter'[Value1])
VAR ToggleState = SELECTEDVALUE('Toggle'[Field])
RETURN
SWITCH(
TRUE(),
SelectedMetric = "Sum Revenue", SUM('Sales'[Revenue]),
SelectedMetric = "Average Revenue" && ToggleState = "On", AVERAGE('Sales'[Revenue]),
SelectedMetric = "Predicted Revenue" && ToggleState = "On", SUM('Sales'[Predicted Revenue]),
BLANK()
)
and use the values in the line chart, so now when you select ON you can see 3 legend values , when you select off it will only show 1 legend value
Hi,
For clarity, what does Value1 refer to in your example?
I tried this and got a composite key error, so i switched the SelectedMetric function from SelectedValue to Max and it's not displaying properly at all. Wonder if I'm using the wrong field though.
Value1 is the first column of the parameter table ,
you can find the sample pbix file in here : https://filebin.net/cx6khb8b62d55pj4
Ah ok - I had the Metric Parameter table set up as a Field Parameter; i've now changed it to a simple table as in your example (and changed back from Max to SelectedValue) and it works. Many thanks.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!