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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ENB15
New Member

How to add conditional visual element to line chart

Hi,

 

I'd like to add a line and textbox to my chart that only appears when a certain filter is selected and isn't visible on other filtered views. This is for a multi-platform line chart showing awareness, and I want to add text boxes explaining specific spikes in the data that's only relevant to the platform being displayed e.g. viral posts on Twitter that disappear when switching to the Facebook filter. Below is what I'm hoping to end up with:

 

ENB15_0-1710423076453.png

ENB15_1-1710423093774.png

 

Is there a way I can hide lines/text boxes when a certain filter is or isn't applied?

 

Thanks!

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ENB15 ,

To achieve this, Power BI currently doesn't support conditional visibility of visual elements (like lines or text boxes) directly based on slicer selections or filters in a straightforward manner. However, you can utilize a workaround that involves creating measures that return values conditionally based on your filter selection and then using these measures to drive the visibility of annotations in your chart. Here's a concise action plan:

1.Create a Measure for Conditional Display: You'll need to create a DAX measure that evaluates to different values based on the filter applied. For instance, if you want a text box to appear for Twitter data, the measure could return 1 when the Twitter filter is applied and 0 otherwise.

DisplayAnnotation = IF(SELECTEDVALUE(YourTable[Platform]) = "Twitter", 1, 0)

2.Use the Measure to Control Annotation Visibility: While you cannot directly hide/show text boxes, you can create a card visual next to your line chart that uses the measure. You can then use conditional formatting to make the card appear blank (by setting font and background to the same color) when the measure returns 0, and display your annotation when it returns.

3.Dynamic Line for Specific Data Points: For highlighting specific data points or spikes, consider using a combination of scatter charts or conditional formatting within your line chart to dynamically highlight these points based on the same measure logic.

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @ENB15 ,

To achieve this, Power BI currently doesn't support conditional visibility of visual elements (like lines or text boxes) directly based on slicer selections or filters in a straightforward manner. However, you can utilize a workaround that involves creating measures that return values conditionally based on your filter selection and then using these measures to drive the visibility of annotations in your chart. Here's a concise action plan:

1.Create a Measure for Conditional Display: You'll need to create a DAX measure that evaluates to different values based on the filter applied. For instance, if you want a text box to appear for Twitter data, the measure could return 1 when the Twitter filter is applied and 0 otherwise.

DisplayAnnotation = IF(SELECTEDVALUE(YourTable[Platform]) = "Twitter", 1, 0)

2.Use the Measure to Control Annotation Visibility: While you cannot directly hide/show text boxes, you can create a card visual next to your line chart that uses the measure. You can then use conditional formatting to make the card appear blank (by setting font and background to the same color) when the measure returns 0, and display your annotation when it returns.

3.Dynamic Line for Specific Data Points: For highlighting specific data points or spikes, consider using a combination of scatter charts or conditional formatting within your line chart to dynamically highlight these points based on the same measure logic.

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors