Excel Line Chart with separate data points for a single line - excel

I have a weird problem that google's not being too kind on results (mostly basic things on how to create a line chart, or combination charts, neither of which I'm after).
I'm trying to automate a report we do each month, I've managed pretty well so far by having a linked excel chart and objects, I have a single sheet in excel I paste my formatted data (set format is consistent each month) then excel picks out the data, creates the charts and when opening powerpoint it reads it all in from there.
Great! Until I was given a new piece of information, there's monthly data and a yearly tally in my data, monthly data is shown with a particular "weighting" applied, year with a different one and it's this that's caused a problem.
The package that's exporting the data can't show these figures contiguously, so we have an export with all the monthly weights, then with annual weights.
So say originally we were looking at C83 to O83 for our data for this year, we're now looking at C83 to N83 and O1364.
I've tried to look at how I would add this to the chart, which currently has the reference:
='Monthly Data to Update'!$C$83:$O$83
But doing anything + or & doesn't seem to work.
So, I decided to just pull all my data in to contiguous set to reference, (so ='Monthly Data to Update'!C83 one cell, ='Monthly Data to Update'!C84 next cell and so on).
This caused a problem for future months that're empty, having 0's in them, so I updated my code to check:
=IF('Monthly Data to Update'!C83=0,NA(),'Monthly Data to Update'!C83)
And this works, my table below my chart is blank for the empty months, my chart doesn't try and plot these empty months. Hurrah!
Now, the wrinkle. The Yearly nets aren't charted but are displayed in the table (I'm not up on Excel charts so how this was originally setup, I just copied the charts from Powerpoint in to Excel and reset the data to where it needed to be before copying it back to Powerpoint as a data linked chart).
First chart I did, works fine, second chart I did it's decided to start plotting the annual net for two of the three lines = \
So, this is how my chart looks like, running off the contiguous (but wrong) data:
And this is how it looks running off the fetched contiguous (correct) data:
It's really baffling, Exceeded and Met now plot the Year to Date figure, whereas Not Met behaves as it should, and they all have the same data layout (on the right) using the same formulas (just pointing at different cells).
I am confused..
I'm hoping to keep this light and simple so have avoided using any macro's to date, so that down the line when I hand this project over to someone any maintenance should be easy to do (say add a chart) without them asking me and me then having to remember what the hell I did a few months ago.. - so if this is doable without going down that line (which, seems like it should be, given my first chart the two lines there worked fine, and one of the three in this is behaving itself).
Apologies for the long winded description, I've given full history so if there's a step further back I could've done better, then happy to fix it up there rather than where I got to.

Ah, so apparently I could've had non-contiguous data with a comma, not a plus or ampersand, so the chart data would be:
=('Monthly Data to Update'!$C$83:$N$83,'Monthly Data to Update'!$O$1404)
So I don't need to rebuild the data in to a contiguous set, and my charts don't cock up when selecting the data this way, win's all around.
Thank you for your time, hopefully this helps someone in the future. (as a saving grace for my lost morning)

Related

Adding new data series changes Excel 2016 chart format

I'm adding a new series to a chart I have and Excel 2016 (Windows 10) keeps changing the format, automatically. I'm a very experienced user and don't recollect ever having this issue. Here is the chart before any changes:
Here is what happens when I add another prices series (same dates as the share price on the chart but adjusted for dividends):
I tried going to Options / Advanced / Charts and unselecting both "Properties follow chart data point for all new workbooks" and "Properties follow chart data point for current workbook" - didn't help.
If I open my Visual Basic Editor and click on "ThisWorkbook", the ChartDataPointTrack is indeed selected to "False".
So what am I missing here?
Extra info #1:
Given 'Terry W' question about data samples, to avoid dumping too much info here, I will describe what they are ( I don't think this is the issue, as there is nothing special on the data; all series are scatter-plots):
the share prices are daily share prices for Coca-Cola [KO]. The original series was the regular share price anyone sees on a day-to-day basis, the series I added was the "Adjusted Price" (i.e., the historical share price adjusted for dividends).
The historical dots in red/light-red are quarterly earnings (annualized) - so not a lot of data
The dots in the future are just one per year - so very little data
Extra info #2:
I noticed that when adding a new series (done by [i] right-clicking on the chart, [ii] clicking on "Select Data..." and [iii] clicking on "Add") but limiting the number of days added, the formating holds! See the picture below: I added 2,000 days of data vs. the 5,500 days I have for the other price series.
I was able to go up to 4,000 days with no issues. As soon as I used "5000", it changed the format. By "used" I mean, changing the reference on the window below you see superimposed to the chart:
Extra info #3:
As you noticed, my charts are in a dark format. This is because I work long hours with spreadsheets and dark formats are much more gentle on my tired eyes (I have posted a macro I wrote to darken spreadsheets here). When converting some charts to dark format, I could have used a macro like the one below. I'm not sure if that was the case for this specific chart, but decided to add the code anyways in case it helps someone to solve the mystery:
Dim s_name As String
For Each Shape In ActiveSheet.Shapes
s_name = Shape.Name
' Format all charts to style #209
If Shape.Type = msoChart Then
ActiveSheet.ChartObjects(s_name).Activate
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 209
ActiveSheet.Shapes(s_name).ZOrder msoSendToBack
End If
I had a similar problem with a macro that would add series to the chart. My issue turned out to be that I was setting the chart type to xlXYScatter before adding the new series. This was resetting the formats of series already on the chart to the default for that type, which is not what I wanted. In my case, leaving the chart type and explicitly setting the new series' format in the macro fixed the problem.
While that was not happening with the original poster's situation, I has me wondering if crossing the data series threshold implicitly changed the chart type.

How to print all the chart properties in Python-pptx

I have a existing chart in pptx file, i just want to update its values on daily basis, these charts are already plotted from excel and paste into pptx, i just want to modify the charts ,
but i don't know how many properties are there in charts like series, category and title properties.
i am able to print the chart series and category data, but when i modify these with chart.replace_data(chart_data)
i am getting error like below
return self._chart_part.related_parts[xlsx_part_rId]
KeyError: 'rId4'
I ma using below code to print the values ,
for series in chart.plots:
for i in series.categories:
cat_list.append(i)
for series in chart.series:
for value in series.values:
ser_list.append(value)
the graph looks like below
How can i modify such graphs with updated values which i will be passing from excel to pptx.
I suspect the problem is rooted in the "pasting from Excel" step.
One thing you can try is to right-click on the chart and choose "Edit values in Excel". If that doesn't work for any reason, that would explain the error you're seeing. If it does work, try saving and run the python-pptx code against the saved version.
An alternative, perhaps more reliable fix would be to recreate the chart natively in PowerPoint, starting from adding a new column-chart and adjusting it until you get what you see here. Then you should be able to update it daily with pretty much the code you mentioned (although your ser_list variable will accumulate values for all series in the chart if there is more than one).
To understand why this could be happening, it's important to observe that a chart does not have to have an Excel worksheet "behind" it. It can, and perhaps does in this pasting case, simply have fixed literal values that are embedded in the chart XML itself. The up-side of this is the pasting operation doesn't need to create a whole Excel spreadsheet, which might be tricky in a cut-and-paste context. The down-side is the values can't be conveniently changed using the standard methods.
I haven't tried working with one of those lately so I don't know if editing and saving the data adds a new Excel object created from the embedded values or not, but this might explain the behavior you're seeing.

Excel label creating

I have the following problem! I am working in a restaurant, and I am in charge to prepare food labels for our buffet on a daily basis. I do know my way around excel. But still it gives me a headache to maintain hundreds of labels. The main problem is that they all have to contain a small picture, as a header, if I simply copy paste it through the cells, it starts to add up on each other and the sheet becomes slow and unresponsive. Is there a way or a macro to manage all these small pictures per cell?

Pivot chart (Excel) fails to render the data the way I want

I'm creating a piece of Java code to fill data into an excel file. The file is pre-created, inlcuding a pivot chart and some vba code.
Though the java code works, I have some problems getting the pivot chart itself to work. I've included a screenshot with some demodata.
There are several Problems I'd like to solve:
The X-Achis seems to behave like a category-axis, though it is formatted as a date-axis.
Symptoms:
Dates are not ordered automatically, but only if I order the according column in the pivot-table
All dates have the same distance, though there is a gap of 1.5 years in the data
The chartline of cathy has a gap. But i do want the line rendered, even if there are dates without data for cathy
Am I using the wrong chart, did I miss the an important checkbox in the chart options or do I really have to interpolate the data programmatically for every day before filling it into the table?
The last option would be not only be disappointing, but also distort the chart since I want to have the datapoints marked with symbols (like the squares and diamonds on the screenshot)
Any help is appreciated.
Edit
By now this is my solution:
First of all: pivot charts are great, unless you want to visualize randomly ordered dates
I'm going to copy the pivot-data via vba into another sheet and use a regular chart
Gaps in the chartline can be avoided by using a point-diagram (X/Y-data) and selecting "connect datapoints with line" in the Dialog in "datasource > hidden and empty cells" (roughly translated from the german locale)
The vba-code will be extended to set up the diagram to my needs (adjusting range of input data and so on)
Still I'm kind of disappointed. I would have thought this was a usual usecase.
I set up trial workbook.
I based a line chart on a range of data that had a column of dates.
It was NOT pivot chart, just an ordinary one
When I went to the x-axis formatting options and chose "Date axis" I was presented with choices about how to span the dates out (to do what you want).
When I created a chart based on a pivot table using the same data, the x-axis formatting options did not give me the same choices
It would seem that pivot charts do not allow dates to be spanned out.
So you might like to consider basing your chart on a range of data not a pivot table.
I also found this useful page, all about this sort of thing:
here
Harvey

Excel 2003 Charting: Chart Data Too Complex

I have written a macro in excel 2007 to log water-level readings. Once logged, it automatically charts the data for each of the 30 wells. However, when the workbook is opened in Excel 2003, the chart does not work complaining that the chart data is too complex to be displayed (works fine in 2007).
There is one series per well (each well data is logged on a separate worksheet) and has the following formula (so that it will automatically update the chart):
=IF(COUNTA('DW1'!$D:$D)-3>0,OFFSET('DW1'!$D$6,1,0,COUNTA('DW1'!$D:$D)-3), 0)
Where DW1 is the worksheet name containing the data for well DW1.
Any ideas about what is going on? I am using the if statement so that the chart doesn't throw errors if there is no data for a well.
I am thinking that the formulas together exceed the limit of the Series data. Anyway to shorten this or change the formula?
In Excel 2003 and older versions, there is an unavoidable limit of 32,000 data points per series in a chart.
In order to display the chart, you need to reduce the number of data points. Either narrow the limits of the X-axis or use a filtering algorithm to remove some of the 'uninteresting' data points. You probably don't want to just decimate the data indiscriminately, as that may remove some of the highs and lows in the data series that are of interest.
Going to run individual charts for each PZ. Pretty sure I am hitting some kind of limit with the data series formulas, not the data points (as there are really not that many).
I do not have an answer to your question, sorry, but a workaround that might be useful.
I worked on a project about 10 years ago where we were exceeding Excel's data-point limit for charts. As much as I wanted to use Excel for the task, I couldn't get it to work.
I resorted to using Gnuplot for the charts. It was a hassle to introduce another technology, but it performed very well on the task.
Josh -
What's the series formula? What you've posted is a worksheet formula.
The 32k limit on points per series is the same in 2007 as in 97-2003.

Resources