Excel, giving data labels to only the top/bottom X% values - excel

I have a simple line chart that I've added data labels to:
But I don't want all those labels. I only want the top and bottom 10% (arbitrary number) values to be shown. For example, in the picture I'd only want the labels for 51, 54, 57, 61, 66, 68, 74 to show. I can manually delete the other labels but the chart data changes dynamically over time. Is there a method for accomplishing this? The text in those labels is a placeholder right now and will eventually be 6-10 characters long, at which point having all those labels will just be a complete mess.
I'm not real confident in VBA so I'd only like to fall back on that as a last resort.
Edit: Thanks to Scott for his insightful answer. It works perfectly with a manually populated Data Labels column. However, some jury rigging is needed if one wants to populate it dynamically. I used the following formula to populate it:
=IF(OR(O1=LARGE($O$1:$O$30,1),O1=LARGE($O$1:$O$30,2),O1=LARGE($O$1:$O$30,3)),O1,"")
Basically, it copies cell values from column O to column P if the value in O is the top 1st, 2nd, or 3rd value in the list. If it's not any of those, it leaves the cell blank. But even if a cell is visually blank, Excel's charting functions interprets the value as 0 if there is a formula in the cell. This means the entire bottom of the graph has repeated data labels of "0%". To solve this I set the value of the FALSE parameter as a negative number and then changed the minimum value on the graph from automatic to 0. This leaves the unfit values below the bottom of the chart, out of visible range.

AHA!
Just when I thought there was no non-VBA solution other than picture links, my ingenuity came through :)
Here is what you can do, in stages:
1) Create a data set next to your original series column with only the values you want labels for (again, this can be formula driven to only select the top / bottom n values). See column D below.
2) Add this data series to the chart and show the data labels.
3) Set the line color to No Line, so that it does not appear!
4) Volia! See Below!

Related

Excel 2013: Label deconfliction in labeled scatter plot

In Excel 2013, I am labeling a scatter plot with values from cells. I'd like the labels to not overlap. I can manually move labels, but I've created a filter to automatically create new plots, so I would like the label deconfliction to happen automatically as well.
Is this possible? Bonus for solutions without VBA.
Example of overlapping labels below:
Here's a non-VBA solution that works if there aren't too many points and the range of values is fairly stable.
It works by splitting your Y series into two separate series, one which has labels above the points and one which has labels below the points.
By default, points will be put into the series with labels below the point. However, for each point, the splitting formula checks whether there is another nearby point that is below or level to the current point. If there is, then the current point is put into the series with labels above the point instead.
I'm assuming you have data in 3 columns: Filter, X, Y. (This also works if you're just filtering on X or Y, you can ignore the Filter column)
Four working columns are required. The first two are X Filtered and Y Filtered.
Using the example in my screenshots below, this formula goes into D2 and fills both D and E columns:
=SUBTOTAL(9,B2)
This just causes the data points to go to 0,0 if they're filtered out, so that they're ignored in the splitting formula.
To make things easier to read, set the names of the filtered values to X (D2:D10) and Y (E2:E10)
Then this formula goes into F2 as an array formula, entered using CTRL + SHIFT + ENTER, and then filled down.
=IF(SUM((ABS(D2-X)<0.75)*(E2-Y>0)*(E2-Y<0.75))+(SUM((ABS(D2-$D$2:D2)<0.75)*($E$2:E2=E2))>1),E2,NA())
This formula creates the series with labels above the point. The formula does two checks:
Checks if there are any other points that are "close" and below the current point.
Checks if there are any previous points that are "close" and level to the current point. (For this check, we can't compare to all points otherwise both points will have labels above the point. We only check up the current point so that the first point still has a label below and subsequent points have a label above.)
If either of these conditions are met, then the value is used, otherwise NA() is used (so that no point is displayed).
In this formula, close is defined as "0.75" on both the X and Y axis. You'll need to change these values in your formula based on what is "close" in your data. I.e. what difference in X and Y values requires labels to be placed on opposite sides of the points.
This formula then goes into G2 to create the series with labels below the point, which is all remaining values:
=IF(ISERROR(F2),E2,NA())
One trick is just required to make the autofilter work on the data. Because we used the SUBTOTAL formula, Excel thinks the last row is a subtotal row and automatically excludes it from the autofilter, even if we select all of the data before applying the autofilter. To use an autofilter, you'll actually need to create an extra dummy row with no subtotal functions before creating the autofilter.
Now, create the scatter plot with 2 series:
Series 1 using X and Y Above
Series 2 using X and Y Below
(No need to include a blank row in these data series)
Format both series to be the same in all details, except Series 1 has labels displayed above points and Series 2 has labels displayed below points.
My screenshots below show results, including when filtering. Labels will always be below values, unless there is another visible point nearby. Each screenshot also shows one of the formulas.
All points:
Filtered on "a"
Filtered on "b"
EDIT: We can actually make the formula a little smarter to handle multiple close level values. This will alternate each subsequent value between having a label above and below. However, it only works while all values are within the "close" range and only if the data is sorted by X first
=IF(SUM((ABS(D2-X)<0.75)*(E2-Y>0)*(E2-Y<0.75))+(MOD(SUM((ABS(D2-$D$2:D2)<0.75)*($E$2:E2=E2)),2)=0),E2,NA())

Dynamic data chart in x and y axis

I'm developing raport generator with fixed data range.
My row and column number vary from 'A34' to 'V64'. Each active column have same amount of rows. Active columns are placed next to each other, from left hand side to the right.
Things I've tried:
Chart from table but it does not look good as chart is full-sized no matter of data amount.
Macro record
VBA but I'm stuck after dynamic range on X-axis
Unfortunatelly I cannot post images yet but below is example data, blue represents possible data range
http://oi63.tinypic.com/21zp5d [dot] jpg
Thanks and have good day
Solution is finding data range and exporting that into chart, using VBA.
Start at C34
-Go to the right till you find first empty cell
-Go to the bottom till you find first empty cell
Now you can work on x,y coordinates and create your data range.
But I'm still open to new ideas

Order by values in an Excel chart

I'm trying to find a simple way, inside an Excel chart, to order by values descending. The largest value would appear at the far left in the chart, with all subsequent values, moving to the right, decreasing in value. I'd like to do this without having to modify any of the data.
You can accomplish this by using a pivot table and chart. This will not affect the original data.
The problem with "I'd like to do this without having to modify any of the data" is that excel is not set up to do that. The chart is making assumptions, here is an example. In Cell A1 we have 1. in A2 we have 2 and on up to A20 = 20. If you chart this using a line chart, you will get a positive curve going from 1 to 20 BECAUSE the data was sorted from least to greatest. If you want the line to have a specific curve you have to SORT your data in a way that will force that curve. You do not have to edit the data, per se, but do have to sort it. If you can provide more specific information on what you are charting I'd be glad to see if I can help.

Ignore cells on Excel line graph

I am trying to draw a line graph in Excel 2010. The y column data source has some gaps in it and I want these to be ignored for the graph. Seems to default these to zero. I know the "Hidden and Empty Cell Settings" exists, but this is only giving the option to set it to zero. Any other way to get my graph looking the way I want it
Image available once I have enough reputation!
if the data is the result of a formula, then it will never be empty (even if you set it to ""), as having a formula is not the same as an empty cell
There are 2 methods, depending on how static the data is.
The easiest fix is to clear the cells that return empty strings, but that means you will have to fix things if data changes
the other fix involves a little editing of the formula, so instead of setting it equal to "", you set it equal to NA().
For example, if you have =IF(A1=0,"",B1/A1), you would change that to =IF(A1=0,NA(),B1/A1).
This will create the gaps you desire, and will also reflect updates to the data so you don't have to keep fixing it every time
In Excel 2007 you have the option to show empty cells as gaps, zero or connect data points with a line (I assume it's similar for Excel 2010):
If none of these are optimal and you have a "chunk" of data points (or even single ones) missing, you can group-and-hide them, which will remove them from the chart.
Before hiding:
After hiding:
In the value or values you want to separate, enter the =NA() formula. This will appear that the value is skipped but the preceding and following data points will be joined by the series line.
Enter the data you want to skip in the same location as the original (row or column) but add it as a new series. Add the new series to your chart.
Format the new data point to match the original series format (color, shape, etc.). It will appear as though the data point was just skipped in the original series but will still show on your chart if you want to label it or add a callout.
There are many cases in which gaps are desired in a chart.
I am currently trying to make a plot of flow rate in a heating system vs. the time of day. I have data for two months. I want to plot only vs. the time of day from 00:00 to 23:59, which causes lines to be drawn between 23:59 and 00:01 of the next day which extend across the chart and disturb the otherwise regular daily variation.
Using the NA() formula (in German NV()) causes Excel to ignore the cells, but instead the previous and following points are simply connected, which has the same problem with lines across the chart.
The only solution I have been able to find is to delete the formulas from the cells which should create the gaps.
Using an IF formula with "" as its value for the gaps makes Excel interpret the X-values as string labels (shudder) for the chart instead of numbers (and makes me swear about the people who wrote that requirement).
Not for blanks in the middle of a range, but this works for a complex chart from a start date until infinity (ie no need to adjust the chart's data source each time informatiom is added), without showing any lines for dates that have not yet been entered. As you add dates and data to the spreadsheet, the chart expands. Without it, the chart has a brain hemorrhage.
So, to count a complex range of conditions over an extended period of time but only if the date of the events is not blank :
=IF($B6<>"",(COUNTIF($O6:$O6,Q$5)),"") returns “#N/A” if there is no date in column B.
In other words, "count apples or oranges or whatever in column O (as determined by what is in Q5) but only if column B (the dates) is not blank". By returning “#N/A”, the chart will skip the "blank" rows (blank as in a zero value or rather "#N/A").
From that table of returned values you can make a chart from a date in the past to infinity

Coloring the points of an excel chart based on another cell

I would like to graphically represent how some real valued data has been discretized/binned. I have an array of real numbers ranging from 1 to 35. For each value, I have a corresponding natural number in the range of -2 to 19. I would like to show all of the real numbers on a number line colored based on which natural number corresponds to each one. Is this possible in excel? If not is there something else I can use to accomplish this?
Since you have no y-axis, here's how I would do this: Create an Excel spreadsheet with the numbers 1-35 in Column A, and with the numbers -2 to 19 along the top of Row 1.
In each intersection of the right number with the right color value, enter a 0.
Graph this range, using a line chart with point markers. You will end up with various points along the x-axis, with different colors and shapes, according to the distribution in your table. Now you should completely remove the y-axis (no line, no fill, no labels, no ticks), gridlines, and legend.
Finally, I would edit the various data series, by removing the lines (leaving the markers), and setting all the line markers to use the same shape, with only the colors differing.
You can fudge conditional formatting in Excel charts. Check out the "Conditionally Formatted Line Chart" example in this tutorial:
Conditional Formatting of Excel Charts

Resources