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
EZiamslow
Helper III
Helper III

Target line based on product(s) selection in filter

Target = 
Switch( true(),
SELECTEDVALUE(Table[ProductName]) = "ProductA", 0.80,
SELECTEDVALUE(Table[ProductName]) = "ProductB", 0.72,

SELECTEDVALUE(Table[ProductName]) = "ProductC", 0.72
)

 

Please help!

 

I have a line and clustered column chart. I'm trying to create a target line based on ProductName selection in filters.

 

I don't have any issues when selecting one ProductName at a time. When I select more than one ProductName, I'm getting unexpected results (see ProductB and ProductC image, last image).

 

Trying to accomplish this...

If same target values ProductName are selected, show the correct target value. (for example: selecting ProductB and ProductC at the same time)

If different target values ProductName are selected, show no target value.

 

Target line = pink dotted line

 

ProductB selected: (Good)

TargetLine_B.JPG

 

ProductC selected: (Good)
TargetLine_C.JPG

 

ProductB and ProductC selected: (This is not what I want. I'm trying to get all columns to have the target line)
TargetLine_BC.JPG

1 ACCEPTED SOLUTION

@EZiamslow , Try like

 

Target = if( countrows(allselected(Table[ProductName])) =1 , 
Switch( true(),
"ProductA" in allselected(Table[ProductName]) , 0.80,
"ProductB" in allselected(Table[ProductName]) , 0.72,

"ProductC" in allselected(Table[ProductName]) , 0.72
) , blank())

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@EZiamslow , Try like

 

Target =
Switch( true(),
"ProductA" in allselected(Table[ProductName]) , 0.80,
"ProductB" in allselected(Table[ProductName]) , 0.72,

"ProductC" in allselected(Table[ProductName]) , 0.72
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

Thank you for helping.

 

That solved the issue of selecting both ProductB and ProductC. (Good)

TargetLine_BC_good.JPG

 

However, when I select ProductA (80%) and ProductB (72%), the target is showing 80%. How do I make it so it doesn't show any target when selecting different values.

 

 

When I select all three, it shows 80%. I don't want to show anything.

 

@EZiamslow , Try like

 

Target = if( countrows(allselected(Table[ProductName])) =1 , 
Switch( true(),
"ProductA" in allselected(Table[ProductName]) , 0.80,
"ProductB" in allselected(Table[ProductName]) , 0.72,

"ProductC" in allselected(Table[ProductName]) , 0.72
) , blank())

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

now, I can only select one ProductName at a time, even for the same target values.

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors