Dynamic vertical reference line in Line Chart

Hi,

How to add dynamic vertical reference line in a Line Chart.
I want to mark previous day in a line with a blue line , also the data label should be blue for yesterday and today.

I have tried to do it with Line & Column Chart (pbix attached), but the width of the band is big.
This is what I want:

If this is difficult , how to change the data label colour only for yesterday and today (without line)

Dynamic Vertical Reference line in Line Chart.pbix (169.8 KB) (upload://aIeU51eN51rFCIPTOONxmFkZqnI.pbix) (169.8 KB) SAMPLE.xlsx (40.5 KB)

Hello @Anu,

Thank you for posting the query onto Forum.

I’m providing a link below where it shows how one can add a reference line.

Hoping you find this useful.

Thanks & Warm Regards,
Harsh

The above video is over a long period, so the reference line appears as a “line”.
But if we do the same for short period,(say, X axis only has 7 Days ) , then the line will appear as “band” not line.
How to control the thickness of column ?

Hi @Anu

I would rather choose a line chart which helps you add the secondary axis and I would say this might solve your problem if your management agree to it.

For me it does solve my purpose as I can show my today value with a dot in the chart.

As per your above requirement as you’re displaying single day value so and your y-axis is in days so I think it would not be possible to display a line as per your expectation.

Thanks,
Ankit

Hello @Anu,

Since the time frame selected by you is very short the width of the “Reference Line” can only be reduced upto a certain extent by selecting the option of “Inner Padding” under the X - axis.

I’m attaching the screen shot as well as the PBIX file of the working.

Hoping you find this useful.

Thanks & Regards,
Harsh

Dynamic Vertical Reference line in Line Chart.pbix (179.6 KB)

Hi @Anu,

There may be an option to change the color of the data point for today and yesterday by using the following measure:

Last 2 days =
VAR Currentday =
MAX ( DATA[DATE] )
VAR Yesterday =
CALCULATE ( Currentday; DATEADD ( ‘Date’[Date]; -1; DAY ) )
VAR Thisday =
TODAY () - 1
VAR Last2days =
IF (
DATE ( YEAR ( Currentday ); DAY ( Currentday ); 1 )
= DATE ( YEAR ( TODAY () ); DAY ( TODAY () ); 1 )
|| DATE ( YEAR ( Yesterday ); DAY ( Yesterday ); 1 )
= DATE ( YEAR ( Thisday ); DAY ( Thisday ); 1 );
1;
0
)
RETURN
Last2days

The next thing you can do is use this measure in a rule for conditional formatting of the visual.

Then you end up with something like this:

or

I have added the pbix file
Hope it helps!

Daniel

Dynamic Vertical Reference line in Line Chart.pbix (173.2 KB)

1 Like

HI @Anu, did the response provided by the contributors help you solve your query? If not, how far did you get, and what kind of help you need further? If yes, kindly mark the thread as solved. Thanks!