Is there a way to automatically or programmatically insert dynamic errorbars in a pivot-chart in Excel? - excel

I have a pivot-chart that uses averages to plot each of my grouped points. I'd like to add errorbars, but Excel doesn't seem to support automatic errorbar generation (or does it?).
Should I just generate a standard graph / pivot-chart all in VBA to include this capability? I'd be losing most of the nice slicer features (if the standard chart is the solution) and it makes me sad...
EDIT: Let's look at an example!
Here is a picture of a pivot-chart I made using data from a table in another sheet.
Example
I'd like to add errorbars that are automatically calculated form the standard deviation of the mean. But since a new mean is calculted each time I filter my pivot for a specific combination of filtered fields, then I can't just add errorbars manually each time I change the filtering of my data!

Related

Add line to Scatter Plot

I did a scatterplot with two data series (blue and orange in the picture).
The orange line you see that connects the dots I did manually and I am looking for a way to have this automatic through the chart menu in Excel. Any idea who this can be done?
I am using Excel version 2013
The chart type you are trying to create is called a Step Chart. Unfortunately Excel doesn't natively offer this chart type, but there are several ways to fake them in Excel. You can use an XY chart with Error Bars to produce the horizontal lines, or you can use a column chart with extra in-between data points to fill the gaps between your actual data points, and you can probably also use another hack where you tell Excel that the x axis is a date axis.
It's a bit hard to advise which approach would suit you best without knowing whether your actual data matches the example you've posted or whether it differs in some way. If you can elaborate further I'll amend this answer with some examples.
Edit: Since your data is as described, you should be able to use the approaches outlined at https://peltiertech.com/Excel/ChartsHowTo/StepChart.html
Or alternately, just add in extra coordinates to direct Excel where to draw the line:
...and then delete the markers of the data points you want to hide:

Prevent Excel from changing x-axis on a dynamic chart

I wanted to make a dynamic chart that plots out the graph of a standard curve for a bio assay we perform frequently. Often to boost the fit of the curve you may drop one or two data points on either end of the data set. So using vlookups and if statements I have a scheme that performs that data trimming, such that my data always starts in Row 1 and the column length simply shortens.
My table works great, but my xy scatter chart goes bananas on these changes. I have the plot on a log log scale, which looks fine if the full data set is present. I lose the x axis detail when I perform a trim. The x- axis then resets to range of 1 to length of my data set.
How can I prevent this?
UPDATE
I added some information. I know there are VBA ways to do this but I would prefer to keep the spreadsheet as simple as possible. I would think excel should be able to handle this.
So if I have a bad fit I may want to trim the data series either from the beginning or end of the data set. I accomplish that with the spinner buttons to dynamically change the table but the following happens
My formula that updates the columns looks like the following. Its messy.
=IF(ISNA(IF(VLOOKUP(F6,$C$4:$D$11,2,FALSE)+1>8-($B$5-1),"",INDEX(C$4:C$11,VLOOKUP(F6,$C$4:$D$11,2,FALSE)+1))),"",IF(VLOOKUP(F6,$C$4:$D$11,2,FALSE)+1>8-($B$5-1),"",INDEX(C$4:C$11,VLOOKUP(F6,$C$4:$D$11,2,FALSE)+1)))
In the formulas use NA() instead of "". Filling cell with "" does not result in a true empty cell and is the reason why you are experiencing issues with your chart.
Hope that helps.
I may be missing the obvious here, but just hard-code the graph with a range of your choosing. In the sample screenshot, making the graph auto defaults the max range to 100,000. I went in and hard-coded the maximum to 50,000 (circled). Afterwards, the 5th data point is not displayed in the chart. Doesn't matter what the data shows at this point.

Excel 2010: Shading per series for Bar Charts

I have a table of data similar to this:
I want to create a bar chart like this:
But I get this:
or, when I add major gridlines, I get this:
However, I want a quick way to visually differentiate between the different quarters (Q1... Q4) by shading them with a different background color each or marking a border around them.
I don't want to export the chart as an image and edit it because:
1. This is a weekly report, it would be very repetitive and error prone.
2. It would be time consuming when I need to do it for 100s of records.
3. My manager prefers the data and the chart to be sent as part of the report. Hence, changing it to other formats is not possible.
Is it possible to create such a graph using Excel 2010? If so, how? I don't mind writing a macro for this, but am currently lost on the approach.
If you want to do something like this:
It's a bit tricky, but can be done. First you must add a fourth data series so you have the data like this:
Then you have to put the three "real" data series in the secondary axis. You must set the maximum values both in secondary and primary axes to the same value (30 in my example). Next, you delete the secondary axis. And finally, in the fourth series settings you let it overlap and put the separation to zero. Sorry, I don't know the exact english name of the settings, as my Excel is not in english.

Multiple axis line chart in excel

I'm looking for a multiple axis line chart similar to the one in the image below, (which is a javascript chart made by amcharts).
Does excel have an option to draw charts line these? Note there are 3 Y axes, and 3 line charts allowing you to compare data.
Is it possible to get more than 3 data points, each with unique axis on one chart ?
It is possible to get both the primary and secondary axes on one side of the chart by designating the secondary axis for one of the series.
To get the primary axis on the right side with the secondary axis, you need to set to "High" the Axis Labels option in the Format Axis dialog box for the primary axis.
To get the secondary axis on the left side with the primary axis, you need to set to "Low" the Axis Labels option in the Format Axis dialog box for the secondary axis.
I know of no way to get a third set of axis labels on a single chart. You could fake in axis labels & ticks with text boxes and lines, but it would be hard to get everything aligned correctly.
The more feasible route is that suggested by zx8754: Create a second chart, turning off titles, left axes, etc. and lay it over the first chart. See my very crude mockup which hasn't been fine-tuned yet.
The picture you showd in the question is actually a chart made using JavaScript. It is actually very easy to plot multi-axis chart using JavaScript with the help of 3rd party libraries like HighChart.js or D3.js. Here I propose to use the Funfun Excel add-in which allows you to use JavaScript directly in Excel so you could plot chart like you've showed easily in Excel. Here I made an example using Funfun in Excel.
You could see in this chart you have one axis of Rainfall at the left side while two axis of Temperature and Sea-pressure level at the right side. This is also a combination of line chart and bar chart for different datasets. In this example, with the help of the Funfun add-in, I used HighChart.js to plot this chart.
Funfun also has an online editor in which you could test your JavaScript code with you data. You could check the detailed code of this example on the link below.
https://www.funfun.io/1/#/edit/5a43b416b848f771fbcdee2c
Edit: The content on the previous link has been changed so I posted a
new link here. The link below is the original link
https://www.funfun.io/1/#/edit/5a55dc978dfd67466879eb24
If you are satisfied with the result you achieved in the online editor, you could easily load the result into you Excel using the URL above. Of couse first you need to insert the Funfun add-in from Insert - My add-ins. Here are some screenshots showing how you could do this.
Disclosure: I'm a developer of Funfun
There is a way of displaying 3 Y axis see here.
Excel supports Secondary Axis, i.e. only 2 Y axis. Other way would be to chart the 3rd one separately, and overlay on top of the main chart.
An alternative is to normalize the data. Below are three sets of data with widely varying ranges. In the top chart you can see the variation in one series clearly, in another not so clearly, and the third not at all.
In the second range, I have adjusted the series names to include the data range, using this formula in cell C15 and copying it to D15:E15
=C2&" ("&MIN(C3:C9)&" to "&MAX(C3:C9)&")"
I have normalized the values in the data range using this formula in C15 and copying it to the entire range C16:E22
=100*(C3-MIN(C$3:C$9))/(MAX(C$3:C$9)-MIN(C$3:C$9))
In the second chart, you can see a pattern: all series have a low in January, rising to a high in March, and dropping to medium-low value in June or July.
You can modify the normalizing formula however you need:
=100*C3/MAX(C$3:C$9)
=C3/MAX(C$3:C$9)
=(C3-AVERAGE(C$3:C$9))/STDEV(C$3:C$9)
etc.
Taking the answer above as guidance;
I made an extra graph for "hours worked by month", then copy/special-pasted it as a 'linked picture' for use under my other graphs. in other words, I copy pasted my existing graphs over the linked picture made from my new graph with the new axis.. And because it is a linked picture it always updates.
Make it easy on yourself though, make sure you copy an existing graph to build your 'picture' graph - then delete the series or change the data source to what you need as an extra axis. That way you won't have to mess around resizing.
The results were not too bad considering what I wanted to achieve; basically a list of incident frequency bar graph, with a performance tread line, and then a solid 'backdrop' of hours worked.
Thanks to the guy above for the idea!
Best and Free ( maybe only) solution for this is google sheets.
i don't know whether it plots as u expected or not but certainly you can draw multiple axes.
Regards
keerthan

how to create percentage bar chart in excel, similar to "100% stacked column" but with one variable against total value

I thought over a lot for this case, I need to plot a series as percentage value of another series.
e.g, series A is the capacity and B is the usage. I want a percentage plot of B on A. Initially I did this by creating a 100% stack chart with series B vs (A-B). I computed (A-B) on a separate column and used that as a series for this purpose. So far so good.
But now I want to generate multiple charts like this (say 12 different graphs for 12 months' usage). I have 12 columns of usage data and one column of fixed capacity data.
Is there a way to auto-generate this chart without having to create 12 intermediate columns with formula. It seems logical that Excel should have a chart type for representing A on B, just as they have one for A,B on A+B.
Sorry if I am too lengthy or confusing in my description. I did my best here to explain.
Actually I am trying to do the same thing I figured it out. If you have Excel 2007 (not sure if this feature is available in older versions). Select all 3 colums, 1 with the names of your variables, total count, and subtotal of what you are counting. Select column chart. Once the chart is created, right click to format the data series. Under series options there is a slidebar for series overlap, change this value to 100% and wahla, the the 2nd series becomes a percent of the total. Hope this helps!
Excel has common chart types, but even Microsoft doesn't have the resources to provide every possible combination of charting styles. And users are confused enough with the currently available styles.
Excel charts plot the data that they are given. If you need to plot A as a percentage of B, you will need to compute the percentage in a range, and plot this range.
The way I would do this is not to modify the ranges on the worksheet at all.
Write a new function that creates the modified range data you need so that you can return this and use it inside of ApplyTemplate method when creating the chart. The only downside to this is you would need to run a macro/vsto ribbon button to update the chart. as opposed to getting that behaviour for free with a worksheet bound approach.

Resources