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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
dedelman_clng
Community Champion
Community Champion

suppressing X axis constant line when outside of date range

I have a line chart that is connected to a date slicer. On this chart, I have a constant X-axis line whose value is the date of record production (via a measure). When the constant value is in the selected date range, everything works OK. But when the date range does not include the constant value, the value still shows on the line chart, but none of the other measures show outside of the selected dates, leaving a large blank area.

 

Is there a way to suppress a constant line if it is out of range? 

 

Value in specified date range:

PA Good.png

 

Value outside of specified date range:

PA Bad.png

 

Filter properties on the visual in the second instance

PA Filter.png

 

Any ideas?

Thanks

David

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @dedelman_clng 

You can adjust the measure used for the X-axis constant line so that it returns blank when the existing measure value is outside the date range.

If  < Existing Expression > is a reference to the existing measure (or the same expression as the existing measure) you could write something like this, assuming you are using 'Date'[Date] on the X-axis:

Record Production Date =
VAR RecordProductionDate =
    < Existing Expression >
VAR MinDate = MIN ( 'Date'[Date] )
VAR MaxDate = MAX ( 'Date'[Date] )
VAR Result =
    IF (
        AND ( RecordProductionDate >= MinDate, RecordProductionDate <= MaxDate ),
        RecordProductionDate
    )
RETURN
    Result

You could apply similar logic to the Y-axis constant line if you wanted.

 

Note: Constant line measures are evaluated in the overall filter context of the visual.

 

Does this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
dedelman_clng
Community Champion
Community Champion

Thanks @OwenAuger !

 

I thought I had tried that but I may not have done replication of the filter context filter correctly before. Worked as expected this time!

 

David

OwenAuger
Super User
Super User

Hi @dedelman_clng 

You can adjust the measure used for the X-axis constant line so that it returns blank when the existing measure value is outside the date range.

If  < Existing Expression > is a reference to the existing measure (or the same expression as the existing measure) you could write something like this, assuming you are using 'Date'[Date] on the X-axis:

Record Production Date =
VAR RecordProductionDate =
    < Existing Expression >
VAR MinDate = MIN ( 'Date'[Date] )
VAR MaxDate = MAX ( 'Date'[Date] )
VAR Result =
    IF (
        AND ( RecordProductionDate >= MinDate, RecordProductionDate <= MaxDate ),
        RecordProductionDate
    )
RETURN
    Result

You could apply similar logic to the Y-axis constant line if you wanted.

 

Note: Constant line measures are evaluated in the overall filter context of the visual.

 

Does this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.