DAX Solution for Creating a Vertical Line in Line Graph

evandam

New Member
Joined
Dec 10, 2014
Messages
9
Hi all,

I'm not even sure if this is possible, but perhaps there is a workaround. I have a line graph pivot chart from my data model, and I would like to add a vertical line or some other indicator for today's date. Is it possible to create a measure that would run a (close to) vertical line from my lowest value to my highest for the current day/month/year? I'm guessing that trying to create a formula to define an undefined slope is a problem, but who knows...

Thank you!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
One possibility:
  1. Create a measure that evaluates to the maximum value when Date=today (otherwise blank)
  2. Change Series Chart Type to Bar (for that series only)
  3. Make the bar as narrow as possible so that it looks like a line (by increasing gap width).
The measure could be something like this:

Code:
=IF (
    HASONEVALUE ( Dates[Date] ),
    IF (
        VALUES ( Dates[Date] ) = [B]TODAY()[/B]<today>,
        MAXX ( [B]ALL ( Dates[Date] )[/B], [Original measure]<original measure="">)
    )
)
TODAY() and ALL(Dates[Date]) may need to be changed depending how your model defines "today" and which dates you want to calculate the max over.</original></today>
 
Upvote 0
I was actually able to take your measure and simplify it since there is an option for a secondary axis that will auto-scale. Small tweaks to fit my data since my view is actually grouping by month/year, so I'm checking if today's date fits in the range, not an exact match:
Code:
 Today:=IF(MIN(dimDate[FullDate]) <= TODAY() && MAX(dimDate[FullDate]) >= TODAY(), 1)

Thanks again
 
Upvote 0

Forum statistics

Threads
1,224,106
Messages
6,176,380
Members
452,726
Latest member
HaploTheGreat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top