Dynamic chart data series referring to multiple named ranges - excel

I have a chart in Excel 2010, and I want to have a data series that can refer to multiple named ranges based on criteria in another cell. For example, if A1 = 1, the data series will display the data from S_1, and if A1 = 2 it will display the data from X_1. Both S_1 and X_1 are dynamic, and can refer to different data based on other conditions I have.
I've gone into the select data source of the chart, and tried setting the series value of the data series equal to formulas like IF(A1 = 1, S_1, X_1), and CHOOSE(A1,S_1,X_1), but it says these functions aren't valid.
Is the syntax of the formula off, or does excel not accept these formulas in its series value? If it's the latter, what other way is there to achieve the desired result?

I would use another column (could be hidden) to extract the specific data I want to plot.
First, you'll need a list, or some other way to interpret the number in A1 to the specific series you want to show. Than you create a column (for simplicity I assume it is aligned with your data) that fetch the relevant data from the table, and set the chart on it.
Now, step by step:
Define the mapping between the number in A1 and the data series you want to choose. I'll use it as the column number of the data.
Define all the data range as a named range, say data.
Take a new column, and paste this formula in row 1:=INDEX(data,1,$A$1), This will bring the header.
In the cell below type: =IF(ISBLANK(INDEX(data,0,$A$1)),NA(),INDEX(data,0,$A$1)) to bring the data from the relevant series, or #N/A if it's blank.
Drag the 2nd formula all the way down to the lowest row in which any of the series has data in it.
Create a chart based on the new column, and watch how you can chang the value in A1 and see the chart updates.
Tell me if it answers your question ;)

Related

Import data from nth columns to another sheet

I'm trying to import all data from nth columns, starting from the 3rd row, from one worksheet ('Dataimport') to another ('Cleaned Data') in the same spreadsheet, but so far I have only managed to get a specific cell from every nth column:
=INDEX(Dataimport!$C$3:$HI$3;(ROWS($A$1:A1)*6)+1)
Right now I'm doing it manually, using =TRANSPOSE(IMPORTRANGE("1yyb1k0uAdN1XcLWBhNq4jA0eInnePRoUt9IbuXDmfEU";"Dataimport!I3:I300")) in every cell, so that the column data is imported horizontally (this is how it's supposed to look like):
The sheet with data looks like this. Here I want to retrieve data from every 7th column starting from column C:
Any idea how I do this?
Public link:
https://docs.google.com/spreadsheets/d/1hXFiSoduVjcZ6fbOcyp-BfI7m4So-01umLS0kBm-lVI/edit?usp=sharing
Proposed solution
Given your attempt =INDEX(Dataimport!$C$3:$HI$3;(ROWS($A$1:A1)*6)+1), I would suggest using the Google Sheets Formula OFFSET that allows specifying indexes as mathematical operations.
You will be able to specify the column offset with a simple mathematical operation in order to get the next needed indexes for the rows below.
Here is an example:
=TRANSPOSE(OFFSET(Dataimport!C$2:C$199;1;(ROW()-1)*6;199;1))
With this formula you can obtain the right column form the Dataimport Worksheet and then transpose it in order to fit it in a row.
Putting this formula in the Clean Data "D2" Cell will compute a column offset of 6 starting from the 3rd column ("C") considered in the OFFSET formula. Dragging down the formula will adjust the column offset index to the needed 7 columns range.
Reference
OFFSET
I think I have a solution.
I've build a spreadsheet with dummy data and then I made a formula that takes every nth column from the table.
Here is my solution:
https://docs.google.com/spreadsheets/d/1J6x4H_cNczRRo40Ri6Nwa-YnZOISpxZmG4-JZ7tA1kA/copy
First I make an ID column to both tables to let vlookup work
I use vlookup and arrayformula formula for this:
For grabbing multiple columns I use sequence formula within vlookup.
This makes an array of numbers with defined step. So if you can have every 6th column you define step as 6. Here step is defined in cell c23
=ArrayFormula(vlookup(A24:A43,A2:AB21,sequence(1,5,4,C23),false))
Of course it can work in multiple sheets or files. You just need to use importranges instead of standard references to a range.

Can't use INDIRECT in a named range used by an Excel chart

I am setting up several charts that are designed to dynamically select the last rows in a data set, or the number of available rows, if that's smaller. I have that set up and working, but I want all of the charts to use a (dynamically sized) range for the category axis values as well, and I'm running into trouble with that.
If I have categories in column A and values in column B, and a named value 'chtLen, then, say 'values' is a dynamically named range defined by =OFFSET(Sheet1!$B$1,COUNT(Sheet1!$B:$B),0,-MIN(chtLen,COUNT(Sheet1!$B:$B)),1)
Then it's simple to create a 'categories' value as =OFFSET(values,0,-1)
An Excel chart will accept =Book1.xlsx!categories as the range for the category axis values, and everything works. But if I want to always use column A, and grab a range in that column, that is, I want to change 'categories to =OFFSET(INDIRECT(ADDRESS(MIN(ROW(Book1.xlsx!values)),1)),0,0,COUNT(Book1.xlsx!values),1)
While still in the named value editor, both of those options will correctly select the same range. But when I try to change 'categories' to the latter formula, the category axis disappears from the chart. Attempting to edit or add =Book1.xlsx!categories to the chart with that definition results in 'Excel found a problem ... check that cell references, range names, defined names and links to other workbooks in your formulas are correct'.
The only thing I think I am changing is how I am arriving at a range. What am I missing?
I wanted to make sure I shared the solution I got to work. Instead of relying on the ADDRESS/INDIRECT functions, I just did simple algebra. It's ugle, and includes off-by-one errors that have to be corrected, but this works, regardless of the length of the data set:
=offset($A$1, ROW(values)+ROWS(values)-2, 0, -ROWS(values), 1)
That is, if I know I always want to draw my category values from column A, this will figure out how many rows down from the top of the category column my last data point is, and offset down that far, then offset 0 rows, then make the length the same length as the data set, going back up, and the result is one column wide. Not pretty but it works.

How to make an existing chart dynamic

I have already made charts and would like to make it dynamic so that when I add new data (highlighted yellow) the charts will update automatically.
Can someone guide me on how to do this.
Image of sample data for what I am trying to do is attached.
I would advise the use of named formulas for your series data inputs. Your named formulas can be dynamic in nature, in that they search across the row and check for the first blank row of data.
As an example, all the grapsh can have their horizontal axis labels set to the named formula 'validDates', where
validDates is put in the name manager as :
='NTesco'!$C$2:INDEX('NTesco'!$2:$2, MIN(IF('NTesco'!$B$3:$AZZ$3="", COLUMN('NTesco'!$B$3:$AZZ$3), 99999)))
N.B. You could use slightly different variations for each graphs date range if there will be independent data gathering for each corresponding value range. Then you should use that row's row index in the IF logical test argument...
You could also use a formula for the first graph values, such as:
='NTesco'!$C$3:INDEX('NTesco'!$3:$3, MIN(IF('NTesco'!$B$3:$AZZ$3="", COLUMN('NTesco'!$B$3:$AZZ$3), 99999)))
The AIOWHB graph takes values from the 4th row, so would be:
='NTesco'!$C$4:INDEX('NTesco'!$4:$4, MIN(IF('NTesco'!$B$4:$AZZ$4="", COLUMN('NTesco'!$B$4:$AZZ$4), 99999)))
And so on for the other two....

Make rows and columns dynamic so when adding a new row or column the chart automatically updates?

In MS Excel if we want to make a chart then we have to select the data range.
Is there is any way that when new entries (row or column) are added then the chart updates automatically?
I've found this to be challenging for stacked bar charts in Excel 2010. Let's take the case of a simple table with some numbers:
2016 2017
Sam 3 4
Fred 5 6
Alice 3 4
Select the table, right-click on its tab, and select insert chart. Choose stacked bar. Then, choose switch Row/Column. Now, if you go to Design | Select Data, you see a nice formula for the Chart Data Range. If you insert a row, however, and add someone else, you get a discontinuous range and they are not included in the chart. If, however, you first select your data, choose Insert | Table, and tell it it has headers, then you can insert a row, and have it included in the chart automatically as e.g. sales from an extra salesperson.
This happens only if two things occur:
It must be a table, and
It must be a continuous table range for your source data. No skipping columns. Perhaps it might work for a subset of a table.
If either is not true, it breaks it. I would criticize the way it doesn't account for inserted rows, or the way it complains about chart data ranges being too complex and doesn't even show you the text of the chart data to let you edit it, if the columns are out of order (ok, I'm complaining), but while e.g. Libre Office calc lets you edit formulas even when they are complex, it never keeps track of inserted rows to add more data series.
If you use dynamic formulas for the chart, or named regions, it just converts them into cell range references, and fails to account for inserted rows.
Create dynamic named ranges for the labels and each series, and edit the chart data to use these names.
An example for the named range is where the labels might be in column A, and some values in column B
=$B$2:INDEX($B:$B,COUNTA($A:$A))
which is defining a range starting at B2 and ending at the row in column B that corresponds to the last data row in the labels column A.
Add a named range for each series.
When pointing the chart to these names, be sure to preface it with the sheet name, even if you are on that sheet, something like
=Sheet1!2010Amounts

Transform badly formatted excel data into a form for pivot tables

How can I transform data in excel in this form (see image here: http://imgur.com/PgX5r) into something suitable for using in a pivot chart. I need three columns eventually, Date, Country and Score. The amount of data points for each country is not constant.
The easiest way i found without using VBA is to use an array formula :
Add another column on the left of your values (let say Col A)
Set this formula on cell A1: {=INDEX(B:B,MAX(IF(ISEMPTY($C$1:C1),ROW($C$1:C1),ROW($C$1))))}
Validate with CtrlShiftEnter
Drag the formula till the end of your values
Your data are almost suitable for a Pivot Chart. What you can do next is to delete unneeded rows (with country names and headers) or use another formula on another sheet to "duplicate" the data except when unwanted rows (you can then filter the blank data in the pivot chart).

Resources