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

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

Related

Excel Line Chart with separate data points for a single line

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)

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.

Calculated Field

I am trying to create a simple pivot table which will tell me how many community residents reported a particular problem, and what percentage of them reported each problem type. I have a data set with name, and then columns for each type of problem. Here's an small sample of the data set:
I have created a pivot table which sums each of these columns and also provides me the total number of people who reported any type of problem at all. Here's what I have:
I want to add a second column to this pivot table that gives the percent of times each problem type was reported. Sounds simple, but because of the structure of the original data set, I can't figure out how to do it. I can set up formulas outside of the Pivot Table which reference the table, but in doing so I forfeit the ability to graph the percentages on a pivot chart. Any ideas how to create a calculated field for this pivot table?
Just to be clear, what I want is something like this, except all contained in the structure of the pivot table:
Edit: I've changed the example of the data set. Here's an explanation of the pivot table. The values under the "# Reporting Issue" column are counts of all the 1's under each corresponding column in the data set. This meant that I had to add each row to the pivot table independently, as you can see here:
I'm open to the idea that I need to change the formatting of the data set, but I'm not sure of the best way to do it. This was set up initially because it allowed for easy compilation into a data table, but Pivot Tables seem to be a different story.
Hopefully this edit clarifies things.
You need to unpivot your data so that you turn it into a Flat File...something that the PivotTable can consume properly.
The easiest way is to use something called PowerQuery, which is baked in to Excel 2016 but available as a free addin from Microsoft for any other versions. Google PowerQuery Unpivot and you will turn up hundreds of tutorials, such as this one from my good pal Chandoo . PowerQuery looks slightly daunting at first to a first time user, but it is freakin easy once you get your head around how to use it. PQ is by far the best addition to Excel in years. PowerPivot being a close second.
If you can't install PowerQuery, then you can use your current data structure to make a 'staging pivot', and then drag the Values label that will appear in the Columns area to the bottom of the ROWS pane, like in this excerpt from a book I'm writing:
Note that my Year categories are equivalent to your Issues categories.
That will emulate the flat file layout you’re after. All you need to do then is turn this intermediate PivotTable back into a normal range, change that Values heading to Issue, and add a Count heading and you’ve got the flat file you need to build a useable PivotTable.
You can also use VBA. Google Unpivot VBA and turn up hundreds of results, including this blazingly fast code I posted some time back. (Look for the code under the —Update 26 November 2013— heading.)
You can also use the DoubleClick extraction trick.

Excel Pivot chart clears Data Labels when refreshed

I have two identical Pivot Charts (same chart template) on two different data sources. When I hit refresh all both have new data, first one with retained formatting and the second one is missing data labels (usually not all of them but randomly 1 or 2 sets out of 3 total data series). I don't want to mess the file with macros for chart formatting as all but one work just fine.
Does anyone have any idea why there's such behavior? I have checked the options on both carths and are identical.
All help is appreciated.

Excel Pivot Chart Help - Pulling names that contributed to count (VBA?)

I am looking to develop a pivotchart of meaningful data related to employees. Lets say it's a graph of employees with infractions by month.
We have a graph that graphs it based on the COUNT of employees that got an infraction for that month. What I am looking to do is make it very easy for management to see the graph and then see the names that contributed to a large count for a month.
However, upon selecting a certain pivot chart cell (Lets say March had a LOT of infractions on the chart and we want to know who was a part of it). Upon double clicking the cell, it then brings up a "Show Detail" window, we select the cell Name since we want to know the names - however that doesn't help because it just puts the names as part of the legend and screws up the chart.
What are some ways to get it to display the names that contributed to the count for the month? I am thinking something along these lines:
-Upon mousing over the data point of the pivot chart, the tooltip is a list of the names
-Upon clicking on it, it displays a table at the bottom that shows the data from the table that contributed to that month (including names).
Anything along those lines. Any help is much appreciated, I do have experience with VBA - but sadly not in Excel yet.E
The best solution would be to check the PivotTable associated with the PivotChart.
When you show detail on the chart the change will be mirrored in the PivotTable.
For more information check out Overview of PivotTable and PivotChart reports # office.microsoft.com

Resources