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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
PicoProg
Regular Visitor

Hide secondary y-axis based on Filtering

Hello everyone. I'm new to Power BI Desktop. I have the following problem, this is the graph that i have:

PicoProg_1-1708615045765.png

The graph works great. The black line is a reference that we use to see how are we going. 

Now the question is, this reference is anual, so it only works for years. If i enter the year 2023 for example, the reference is still there, but now I'm seeing months so it doesn't make sense to leave it there. Also, it bothers because of the scale of the Y AXIS. So, my question is, how can I hide the black line when I enter a year? For example, hide it here:

PicoProg_2-1708615198795.png

 

It completely ruins my graph.

Thanks in advance!!

3 REPLIES 3
Anonymous
Not applicable

Hi @PicoProg ,

To achieve this, you will need to utilize a combination of measures and conditional formatting to control the visibility of your black line (reference line) based on the selected time period.

Please try below steps:

1. Create a Measure to Determine Visibility: You'll need to create a DAX measure that evaluates the current level of granularity in your report. This measure can check whether the report is filtered to a year or to a more granular level (like months). For example:

Reference Line Visibility = IF(MAX('Date'[Year]) = MIN('Date'[Year]), "Show", "Hide")

This measure assumes you have a 'Date' table with a 'Year' column. It checks if the maximum and minimum year in the current context are the same, implying you're viewing data for a single year. Adjust the logic as needed for your specific scenario.

 

2. Apply Conditional Formatting to Hide the Secondary Y-Axis: While Power BI does not directly support conditional formatting for axis visibility, you can apply a workaround by using the measure to conditionally format the color of the reference line to match the background (effectively hiding it) when the measure dictates. Unfortunately, direct manipulation of the y-axis based on DAX measures is not supported, but this approach targets the visual element you wish to hide.

 

3. Review and Adjust Your Model: Ensure your data model supports the necessary granularity and that your 'Date' table is properly linked to your fact table. This ensures the measure can accurately determine the current level of detail based on the date context.

 

For more details, you could read related document: Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello, thank you for your answer. 

I changed my mind, and now i have another problem. I would like to have a "dinamic" reference. If i'm seeing years, to see the years reference. If I'm seeing months, to see the months reference. I already did the year reference, but it doesn't work on months, so I think to re-do everything, and think it another way.
The table that i have has this style:

 

IDDate 

DATA

 

I have values since 2017. I would like a reference for each year, and if I go into the year, to see a monthly reference. How could I aproach it?

 

Thanks in advance.

_AAndrade
Super User
Super User

Hi,

You can use DAX to do it, but I need to have an pbix sample to try it.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors