add a vertical line on an excel chart - excel

I have a line chart in excel with data already set; I need to add a vertical line that moves according to the X values (month dates). For example for this month the line will move on the X value of "Jul-20"
Below I have attached the screenshot of the chart and the chart data. I have never had my hands on excel chart up until now and this chart has not been made by myself. Any help would be appreciated.
UPDATE 1
Thanks to #Steven Pomponio
when I try to add the new series for the vertical line, I do not have the "Y" values; see screenshot
UPDATE 2
added a new data source with values as 01/072020 and /01/07/2020 in cells J182 and K182; now I see a black dot on the left between the £10.0m and £ 20.0m Y values. If I change the verttical line data source chart type to be "Scatter with straight lines" then I do not even see the point.
If I change teh entire chart to be of Scatter with straight lines then I do see the Series Y Values but the whole chart change design and I do not want to do this.
UPDATE 3
Thanks to #Steven Pomponio I did it

Choose two cells in which you will have your target x value where the vertical line will appear, for this example I'll be using cells (E1) and (E2). Within cell (E1) you'll want to type in the formula =TODAY()-DAY(TODAY())+1 in order to get the first date of the current month. Cell (E2) can just be =E1.
In two cells, preferably next to them you will need to enter in the minimum and maximum bounds of one of your axes (Since you are already using a dual axes). It is important that these numbers are the same as what you set for the axis min & max bounds as this allows for you the line to properly span across the entire chart. Don't leave them on Auto.
Next, right click on your chart and click Select Data -> Add -> and add in the two dates (cells (E1) and (E2)) into the Series X Values, and the min and max bounds into the Series Y Values.
The final step is to make sure that the Chart type for this newly added series is selected as Scatter with Straight Lines and plotted on whichever axis you set the bounds equal to.

Related

Excel Dynamic Chart Title (Top n)

Is it possible to create a dynamic Excel Pivot Chart title that includes "(Top n)" where n = the value filter row limit selected by the user? I know the chart title can be set to the contents of a cell but am unsure how to go about determining the Top n limit selected by the user or how to add that in the cell formula. If this is possible, any assistance would be greatly appreciated. Thanks!
Max didn't work as I need the row count (n) after the user applies a value filter of Top n. However, your response steered me in the right direction and I was able to accomplish what I was looking for with ="(Top "&SUBTOTAL(103, A2:A140) &")" . Supposedly, SUBTOTAL with the first parameter set to 103 will perform a COUNTA function but ignore hidden rows. Reference: https://exceljet.net/excel-functions/excel-subtotal-function
So use max() on the range of cells and concatenate - I like the & (less typing):
=(Top &MAX(A21:A24)&")"
Just for those who don't know how top get the cell result into the title:
Select the chart title box (so it has blue corners
In the formula bar type "=" and select the cell with the contents and enter.

Plot graph using the last 10 values in MS Excel

So I got Sheet1 with a table containing some data. To simplify let's say there's a column 'x' with some data and a column 'y' with some data. Every now and then more values are manually added to the table.
On Sheet2 I need Excel to automatically plot a graph only using the last 10 values in the table. So when more values are added the graph changes automatically to the new last 10 values. Is this possible?
Furthermore, let's say there's a third column 'z' that's always a constant value (for example to show some kind of a maximum for 'y' in the graph). How to make Excel automatically fill the cell with the number when the according 'x' and 'y' cells are filled? I know I could manually fill the 'z' column all the way down but I suspect that would screw up with plotting the last 10 values.
I'm using MS Excel 2013.
Thank you very much!
You'll need to create a chart using dynamic named ranges as the series data.
Start by setting up the data table with headings x, y and z.
Select x heading and click Insert > Table, make sure "My table has headers"
is checked then click OK
In column z, to set 20 as the autofilled value, add formula =20
Put your data in columns x and y
Create your chart based on columns x and y. This example creates a XY Plot.
Assuming you've only got one table in your workbook, it will be named "Table1".
Go to Formulas > Name Manager > New
xPlot: =OFFSET(Table1[[#Headers],[x]],COUNTA(Table1[z])-9,0,10,1)
Also create:
yPlot: =OFFSET(Table1[[#Headers],[y]],COUNTA(Table1[z])-9,0,10,1)
Right click on your chart and click Select Data...
Remove the Series that is there
Create a new Series
If your workbook was called Chart Example.xlsx, then set:
Series X values: 'Chart Example.xlsx'!xPlot
Series Y values: 'Chart Example.xlsx'!yPlot
Click OK and try adding more data.

Excel 2013 Chart X-axis Date Labels

Is there a way to increment date labels by the start of every month in an excel chart?
i.e. Axis values should start in DD/MM/YY:
1/1/16, 1/2/16, 1/3/16....
It depends on the type of chart you use. In line and column charts, you can set the X axis to a date axis and let the major unit be 1 Month.
XY Scatter chart work differently. Here you will need to hide the X axis labels and use a data series to place the markers and add data labels, then format the series to no line and no markers. In the screenshot the series is still visible.
Right click the dates on the x-axis and select "format axis".
Under "Axis Options" you can make the major unit 'fixed' at 1 month. It will then increment by the 1st of each month.
Setting a "minimum" date, will allow for setting the day which it starts (eg, if you wanted it to increment on the 3rd of each month, input 3-Jan-2016. I think the default is the first date in the data set.).
Make sure the category is set to "date" if excel doesn't recognise your date column. "format axis" -> "number" tab, or 'right click' -> 'format cells'.

getting the values from the activechart using excel vba

I have some data, which I have charted as a scatter plot. And I would like to iterate over the points on the chart, and programmatically using VBA determine their
cluster
budget
actual
varaince values
I know I can get (4) variance using the following code, but I am not sure how to get values 1: cluster, 2: budget, 3: actual
Sub t3()
Dim chart As chart
Dim series As series
Dim values As Long
Dim p As Double
Set chart = ActiveChart
Set series = chart.SeriesCollection(1)
p = series.Points.Count
For i = 1 To p
values = series.values(i)
Debug.Print " ", i, values,
Debug.Print ""
Next i
End Sub
Using this information for 1, 2, 3, 4, I will check the cluster, and color the point accordingly A: blue, B, Red, C Green
Then I need to put a legend on the left of the chart with the 3 cluster values and their colors: A: blue, B, Red, C Green
chart
What I want
I chart, colored according to cluster: A, B, or C, where each of A, B, C only appear once in the legend. However the cluster is appearing for each point instead :(
Getting the other values
I'd like to do calculations on each point on the scatter chart, however I am not sure how to get access to the other values (budget and actual), as I am only showing cluster and variance on my chart now.
I simply offset from the start position and stored the values in variables, but I feel there must be a better way of accessing other data in a worksheet to use in a chart? Instead of removing it from the data (when you Select Data >> for the chart, can you hide it and then use it in calculations?
To get the chart only to show each cluster ID once, use this approach. I've added three columns to the data range, one headed by each cluster ID. Select E2:G7, enter this formula
=IF(E$1=$A2,$D2,NA())
and press Ctrl+Enter to fill the selected range with the formula.
Select the shaded range (select one region, then hold CTRL while selecting another) and insert a scatter chart.
Each cluster has a unique legend entry and a distinct format in the chart.
For your other calculations, use formulas in the worksheet.
I don't know why you're calculating your life with VBA when what you need is built right into Excel.

Dynamic Charts with Variables on Two Axes

I'm trying to utilize the Range Names feature in Excel to create a chart that will automatically update once new data is appended. I've successfully done this with two variables (i.e. Date and Temperature) but I'm unable to get it working with 3 or more variables.
Within a tab titled, 'Dynamic', I have a Date (value in A1) column with these values: 4/1/2013, 4/2/2013, 4/3/2013, 4/4/2013, 4/5/2013 (Value in A6).
I also have a Temperature (value in B1) column with these values: 55, 60, 62, 65, 61 (Value in B6).
Within the Name Manager (within Formulas tab) I created a Named Range with a Name of "Date" and a Refers to value of:
=OFFSET(Dynamic!$A$2,0,0,COUNTA(Dynamic!$A:$A)-1)
I created another Named Range with a Name of "Temperatues" and a Refers to value of:
=OFFSET(Dynamic!$B$2,0,0,COUNTA(Dynamic!$B:$B)-1)
I then selected the range A1:B6 and inserted a Clustered Column chart. Clicking on one of the bars yields this formula:
=SERIES(Dynamic!$B$1,Dynamic!$A$2:$A$6,Dynamic!$B$2:$B$6,1)
If I insert my Named Ranges in the above formula like so:
=SERIES(Dynamic!$B$1,Dynamic!Date,Dynamic!Temperatures,1)
and it will allow me to add a new row of data and it automatically updates the chart.
This is great! But when I attempt to add another variable I can't get it to work. I add Rainfall (value in C1) to the spreadsheet with these values: 1, 2, 0.5, 0, 1. I create a Name Range with a Name of "Rainfall" and a Refers to value of:
=OFFSET(Dynamic!$C$2,0,0,COUNTA(Dynamic!$C:$C)-1)
I then select A1:C6, insert a Clustered Column chart. Clicking on one of the Temperature bars I change the formula to:
=SERIES(Dynamic!$B$1,Dynamic!Date,Dynamic!Temperatures,1)
When I attempt to change the formula for the Rainfall bars I try this:
=SERIES(Dynamic!$C$1,Dynamic!Date,Dynamic!Rainfall,2)
but when I hit enter it won't do anything. So, I'm left with a chart that won't update automatically.
Assuming I could get this to work, I'd like to move the Rainfall data onto a secondary axis and change the chart type to a line chart (so that it all fits nicely onto the same chart area).
Can you tell me what I need to do to get this example to work? Thank you!
I couldn't get this to work either, using the SERIES formula. Then again, I suppose it is considered an undocumented feature.
However, if you edit using the Select Data dialog then it works.

Resources