Excel dynamic graph range - excel

Without using VBA macros, is it possible to dynamically set the range of a graph?
I have a table like this:
I want to now create a graph with merely the "valid" amounts of 2,3,4 and 5 as bar chart, say. These valid ranges can change however to 3,4 and 5 say. The valid numbers are always consecutive. so I just need the beginning and end.
I've looked into index, match, and offset, and I just don't get how to accomplish this exactly.
Thanks in advance.

My answer in a nutshell as I have to leave in a few minutes. (I can add details later, if you are interested).
As far as I know, Excel charts do neither allow range names or formula as input, which makes it difficult to set a dynamic range without a VBA macro.
However, if you are only interested in a chart that grows and shrinks with the data, you can use a XY chart do achieve the desired result.
Formulas:
D2: =IF(COUNTBLANK(A2)=1,#NA,COUNTIFS(D$1:D1,">=0")+1)
E2: =D2
F2: =IF(COUNTBLANK(C2)=1,#NA,0)
G2: =IF(COUNTBLANK(C2)=1,#NA,C2)
Chart properties
Just create the maximum number of rows (here 7)
Set the stroke/line width to 30.
Ajust the x-axis to start with 0.5.
Note: Screenshots were made with a German Excel version.
Downsite: The x-axis labels cannot be adjusted easily.

Related

How do you average repeating blocks of cells in Excel?

I am trying to figure out how to average 4 x 4 groups of cells in my spreadsheet across a very large data set. I've tried using OFFSET with a cell range (e.g. B2:E5) but I haven't had success (I don't even know if you can use a range for the reference with OFFSET). This is my first time tackling a problem like this, so any advice would be welcome! A portion of the data set is attached to give an idea of the ranges I would like to average.
If the data was in B2:Q17 you could use this complicated looking formula to return the average for each 4*4 block.
=AVERAGE(INDEX($B$2:$Q$17,(ROWS($2:2)-1)*4+1,(COLUMNS($R:R)-1)*4+1):INDEX($B$2:$Q$17,(ROWS($2:2)-1)*4+4,(COLUMNS($R:R)-1)*4+4))
You would copy this across and down and it could go anywhere on a sheet.
You can use INDEX to refer to a range derived from values fro TopLeft and BottomRight corners, in the form
INDEX(DataRange, TopRow, LeftCol):INDEX(DataRange, BottomRow, RightCol)
Then wrap that in AVERAGE(...)
To demonstrate
=AVERAGE(INDEX($B$7:$AH$903,B1,B2):INDEX($B$7:$AH$903,B3+B1-1,B4+B2-1))
Note: INDEX has the advantage over OFFSET in that it's non-volatle

Find Next Non Zero Values In A Column With Its Subscription

I've a question regarding columns and finding non zero values with there labels.
Hopefully the pictures will make my problem/struggle a bit better to understand.
Basically, there are columns to the right that show labels and hours that a team loaned in or out.
The values are found through a formula that shows per label the totals amount of hours spent.
Now I want to have on my overview page the two columns to the right with only labels showing the labels that contain hours. I've tried to use multiple if variables but that didn't seem to work :(
So at the end it should show something like this (I now manually typed the labels and data):
I did a quick recreation of your data structure to test this.
Using Array Formulas should get you the desired results in the current structure of your worksheet:
For range Loaned in you'd need the formula to be
=IFERROR(INDIRECT(ADDRESS(SMALL(IF($I$4:$I$14>0,ROW($4:$14),""),ROW(A1)),8)),"")
Where 8 is a reference to the return column. For the range directly to the right, you'd use the same formula, just adjust 8 to 9. And for range Loaned Out you'd need
=IFERROR(INDIRECT(ADDRESS(SMALL(IF($K$4:$K$23>0,ROW($4:$23),""),ROW(A1)),10)),"")
And for the range directly to the right you would again change the 10 to a 11. Again, both of these are array formulas, so they have to entered slightly differently. See the link for further assistance with array formulas.
This is not trivial. If you cannot work with filtering or programming, you should make use of matrix formulas. I include an example with two formulas: 1st in D1:D5, 2nd in F2:G5. Enter them with Ctrl+Shift+Enter. Also, you should use an extra column to determine the "valid" rows. (You could put it all in one formula, but it would look even more complicated.)
Sorry for German excel. Wennfehler = iferror, kkleinste = small, zeile = row, wenn = if, bereich.verschieben = range.offset.

Finding average of a set of data within a table between different ranges in Excel 2016

In my spreadsheet, i am trying to determine the average of a set of data in a table between 0-0.5 , 0.5-1 , 1-1.5 and 1.5 up to 2.
the formula that i'm using is :
=AVERAGEIFS(All Data, All Data, CONCATENATE(">",0), All Data, CONCATENATE("<=",0.5)))
However this formula fails.
i have a feeling that i need to use AND function but i dunno where to use it. if it's possible i want to roundup the average value to a 3 decimals.
Thank you heaps
UPDATE:
So i added the dollar signs to my formula and it perfectly worked. Now i just need to ROUNDUP the result in 3 decimals. I don't know where to place ROUNDUP function in the below formula.
=AVERAGEIFS($A$1:$T$20,$A$1:$T$20,CONCATENATE(">",G24),$A$1:$T$20,CONCATENATE("<=",G25))
Looking at the formula in your screenshot, you are using relative addressing. Hence your table reference will change as you fill down the formula. Use absolute addressing instead:
H25: =AVERAGEIFS($A$1:$T$20,$A$1:$T$20,CONCATENATE(">",G24),$A$1:$T$20,CONCATENATE("<=",G25))
To roundup to 3 decimal places, you would wrap your entire formula with that function:
H25: =ROUNDUP(AVERAGEIFS($A$1:$T$20,$A$1:$T$20,CONCATENATE(">",G24),$A$1:$T$20,CONCATENATE("<=",G25)),3)
Note: some people say ROUNDUP when they mean ROUND. Excel has different functions for ROUND and ROUNDUP.
What I would do is compile your data set in one column, give the column a heading and then use the filter function to sort the data in the thresholds you require (data tab>Filter). Click the arrow next to your newly created heading>number filters>between and then choose the range (e.g. 0-0.5). This should then retrieve all the values within this range. Highlight all of the data and copy it to a new spreadsheet, or the same one-whichever you prefer- and use the =AVERAGE function to obtain the average within this range.
Alternatively, you can use the pivot table function available in the 'Insert' tab. Add your data to the 'Columns' and 'Values' field. Right click the cell underneath 'Column Labels'>Group> Starting at 0, Ending at 2.5, By 0.5. Right click a cell in the third row and choose summarize values by average.
I hope this helps.
regards,
Monray

Excel 2010 Chart Data Range Reference

I'm sure this question has inevitably been asked and answered but despite a couple of days of searching I haven't been able to come up with a solution.
In excel (2010) I have a section of data referring to test results. The data looks roughly like this:
Each run inserts a new line at the top (row 2) with the latest results. From this I am trying to produce a chart that shows only the results from the last 7 runs, so the data in B1:E8. I can do by either direct reference, named range or converting to a table. The problem with the first two methods are that when I insert a new line under the headers the range then splits so that I have B1:E1 and B3:E9. The table method is slightly better in that it includes the newly inserted row but keeps the range set to the same bottom row (so it ends up referencing 8 rows of data).
Am i missing something obvious here? I'd prefer the data to be listed like this with the newest on the top, but I'm sure I can change it so the newest is at the bottom if anyone has a good idea!
Thanks in advance!
You can use INDIRECT formula on another worksheet to capture part of your table from Sheet1, like this:
=INDIRECT("Sheet1!B1:E8")
And then specify that as your chart data range.
Just remember to use INDIRECT as array formula:
Enter =INDIRECT("Sheet1!B1:E8") in Sheet2!B1 cell.
Select B1:E8 range.
Press F2 and then Ctrl-Shift-Enter to make it an array formula.
I would use a Pivot Chart.
You can apply a filter on these charts to only look at the Top X results. So if you filter to show Top 7 by Date, then this should do the trick.
You might need to lookup a quick tutorial on Pivots and Pivot Charts if you don;t have any experience though.
They are incredibly valuable though, so I would recommend it regardless.

Creating a chart in Excel that ignores #N/A or blank cells

I am attempting to create a chart with a dynamic data series. Each series in the chart comes from an absolute range, but only a certain amount of that range may have data, and the rest will be #N/A.
The problem is that the chart sticks all of the #N/A cells in as values instead of ignoring them. I have worked around it by using named dynamic ranges (i.e. Insert > Name > Define), but that is extremely inefficient, as each chart has 4 dynamic series, and I must make 25 of these charts.
Are there any other solutions that allow me to specify a range, as normal, for a data series, but tell the chart to ignore all "#N/A" or blank cells?
I was having the same issue by using an IF statement to return an unwanted value to "", and the chart would do as you described.
However, when I used #N/A instead of "" (important, note that it's without the quotation marks as in #N/A and not "#N/A"), the chart ignored the invalid data. I even tried putting in an invalid FALSE statement and it worked the same, the only difference was #NAME? returned as the error in the cell instead of #N/A. I will use a made up IF statement to show you what I mean:
=IF(A1>A2,A3,"")
---> Returned "" into cell when statement is FALSE and plotted on chart
(this is unwanted as you described)
=IF(A1>A2,A3,"#N/A")
---> Returned #N/A as text when statement is FALSE and plotted on chart
(this is also unwanted as you described)
=IF(A1>A2,A3,#N/A)
---> Returned #N/A as Error when statement is FALSE and does not plot on chart (Ideal)
=IF(A1>A2,A3,a)
---> Returned #NAME? as Error when statement is FALSE and does not plot on chart
(Ideal, and this is because any letter without quotations is not a valid statement)
When you refer the chart to a defined Range, it plots all the points in that range, interpreting (for the sake of plotting) errors and blanks as null values.
You are given the option of leaving this as null (gap) or forcing it to zero value. But neither of these resizes the RANGE which the chart series data is pointing to. From what I gather, neither of these are suitable.
If you hide the entire row/column where the #N/A data exists, the chart should ignore these completely. You can do this manually by right-click | hide row, or by using the table AutoFilter. I think this is what you want to accomplish.
Please note that when plotting a line chart, using =NA() (output #N/A) to avoid plotting non existing values will only work for the ends of each series, first and last values. Any #N/A in between two other values will be ignored and bridged.
You are correct that blanks "" or a string "#N/A" are indeed interpreted as having values in excel. You need to use a function NA().
If you have an x and y column that you want to scatterplot, but not all of the cells in one of the columns is populated with meaningful values (i.e. some of them have #DIV/0!), then insert a new column next to the offending column and type =IFERROR(A2, #N/A), where A2 is the value in the offending column.
This will return #N/A if there is a #DIV/0! and will return the good value otherwise. Now make your plot with your new column and Excel ignores #N/A value and will not plot them as zeroes.
Important: do not output "#N/A" in the formula, just output #N/A.
You can use the function "=IF(ISERROR(A1);0;A1)" this will show zero if the cell A1 contains an errore or the real value if it doesn't.
I was having the same problem.
There is a difference between a Bar chart and a Stacked Bar chart
As there is a difference between a Line chart and a Stacked Line chart.
The stacked one, will not ignore the 0 or blank values, but will show a cumulative value according with the other legends.
Simply right click the graph, click Change Chart Type and pick a non-stacked chart.
just wanted to put my 2cents in about this issue...
I had a similar need where i was pulling data from another table via INDEX/MATCH, and it was difficult to distinguish between a real 0 value vs. a 0 value because of no match (for example for a column chart that shows the progress of values over the 12 months and where we are only in february but the rest of the months data is not available yet and the column chart still showed 0's everywhere for Mar to Dec)
What i ended up doing is create a new series and plot this new series on the graph as a line chart and then i hid the line chart by choosing not to display the line in the options and i put the data labels on top, the formula for the values for this new series was something like :
=IF(LEN([#[column1]])=0,NA(),[#[column1]])
I used LEN as a validation because ISEMPTY/ISBLANK didn't work because the result of the INDEX/MATCH always returned something other than a blank even though i had put a "" after the IFERROR...
On the line chart the error value NA() makes it so that the value isn't displayed ...so this worked out for me...
I guess it's a bit difficult to follow this procedure without pictures, but i hope it paints some kind of picture to allow you to use a workaround if you have a similar case like mine
One solution is that the chart/graph doesn't show the hidden rows.
You can test this features doing: 1)right click on row number 2)click on hide.
For doing it automatically, this is the simple code:
For Each r In worksheet.Range("A1:A200")
If r.Value = "" Then
r.EntireRow.Hidden = True
Else:
r.EntireRow.Hidden = False
Next
There is another much less known solution which has merit in some places. Use the #NULL! error which does not plot and does not create a zero point for the plot.
So your plot column is filled with the following construct. Assume real data in column A and that the plotted version is in column C.
=If(Isnumber(A2),A2,A2 A3)
That space is a little known operator to produce the intersection of the two cell addresses or ranges. If there is no intersection then it produces the message #NULL!
Cells containing #NULL! are skipped for plotting purposes.
Aside (For Microsoft) just need to get the maths equations to ignore such cells somehow?
This is what I found as I was plotting only 3 cells from each 4 columns lumped together. My chart has a merged cell with the date which is my x axis. The problem: BC26-BE27 are plotting as ZERO on my chart. enter image description here
I click on the filter on the side of the chart and found where it is showing all the columns for which the data points are charted. I unchecked the boxes that do not have values.
enter image description here
It worked for me.
I had a similar issue using an X/Y chart but then also needed to calculate the correlation function on the two sets of Data.
=IF(A1>A2,A3,#N/A) allows the chart to be plotted but correlation of X & Y fails.
I solved this by
=IF(A1>A2,A3,FALSE)
The FALSE can then be removed using conditional formatting or other tricks
If you make the vertical scale on your chart (using format axis) run from 0.0001 (say) then a value that Excel thinks is zero will not be plotted. Your axis in the chart will still look like it runs from zero upwards.
If you use PowerPivot and PivotChart, you will exclude non-existing rows.
I found a way to do it.
you can do an x,y scatterplot. it will ignore null records (i.e. rows)
I had the same problem with a full line appearing.
The end of my data only had #N/A.
When I changed the chart type from a stacked line to line then the end of the line was removed from the chart.
This did not work if the #N/A was in the middle of the data, only when it was in the trailing data.
Select the labels above the bar.
Format Data Labels.
Instead of selecting "VALUE" (unclick).
SELECT Value from cells. Select the value.
Use the following statement: if(cellvalue="","",cellvalue)
where cellvalue is what ever the calculation is in the cell.
While this is an old post, I recently came across it when I was looking for a solution to the same issue. While the above solutions do prevent charts from plotting data (when source cells are #N/A or made to look blank), it doesn't resolve the issue of the chart data labels themselves still showing a zero label.
I had searched and searched and almost given up, when I came across the solution posted online # https://www.extendoffice.com/documents/excel/2031-excel-hide-zero-data-labels.html
It worked liked a charm. Attached is an image showing an example of how the data (labels) displayed before, Chart#1, and how it displays using this tip chart#2.
enter image description here
I found the following solution:
The Excel charts adjust automatically to the correct axis ends if all the date series cells which should not be included in the axis timeframe contain "". So, you can make a helper column and write something like this into the Date series helper column cells:
Helper Column Datecell = If( iserror (ValueCell);""; Datecell)
On the other hand, if you want to resize your chart to a given timeframe you can write something like this into the helper column date series cells:
Helper Column Datecell = IF( OR(ISERROR(ValueCell); DateCell>DateInput) ;"";DateCell)
DateInput is a cell where you input a date to resize the chart.
There is another topic here:
Regarding that if you make a helper column to a value series cell giving an NA() Error the value series adjusts to your series as well:
you could even make your value series cells dependent on your given input cell. I think this is also needed.
Helper Column Value Cell: if( condition that date cell is too big or bigger than a given input cell; NA(); ValueCell)
Best way is use Empty
Dim i as Integer
For i = 1 to 1000
If CPT_DB.Cells(i, 1) > 100 Then
CPT_DB.Cells(i, 2) = CPT_DB.Cells(i, 1)
Else
CPT_DB.Cells(i, 2) = Empty //**********************
End If
Next i

Resources