Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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:
Value outside of specified date range:
Filter properties on the visual in the second instance
Any ideas?
Thanks
David
Solved! Go to Solution.
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?
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
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?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
69 | |
60 | |
51 | |
36 | |
36 |
User | Count |
---|---|
84 | |
70 | |
58 | |
45 | |
44 |