Little help needed here with excel dynamic named ranges.
I know how to make a dynamic named range that adjusts row height depending on the size of the range (no. rows with data in):
=OFFSET(Helper!$DJ$3,0,0,SUM(--(Helper!$DJ$3:$DJ$30<>"")))
However I find myself working with a large(ish) range of data across multiple columns - about 100 - and I REALLY want to avoid making 100 named ranges.
It must be possible to create a single named range that references the whole data set (DJ3:HE30) and the formula dynamically chooses which column to look at and (as before) chooses how many rows to return in that specific column.
The closest I've got is this:
=OFFSET(Helper!$DJ$3,0,0,SUM(--(Helper!$DJ$3:$DJ$30<>"")),SUM(--(Helper!$DJ$3:$HE$3<>"")))
But this just goes to the last column with data in (which makes sense really as it's doing the same thing with columns as it is with rows).
I'm assuming I need to tweak the starting point of the offset ref and somehow pass that column to the rest of the formula.
These named ranges are going to be used for drop-downs so the first drop-down will be the criteria that needs to be passed on to the second drop-down (that will utilize this new funky named range).
For example - if my first drop-down uses criteria 1,2,3 etc - my second drop-down would need to display results like this:
Option 1 = A,B,C
Option 2 = D,E,F
Option 3 = G,H,I
So the lists containing the letters in this example are all in individual columns, so the dynamic range needs to identify which column to use to pull the right list.
Also, with the number of columns I think I need to make this an INDEX rather than an OFFSET.
Can anyone point me in the right direction?
Thanks in advance, much appreciated!
It looks like I have managed to solve this one myself.
What I have done is create 2 named ranges as helper cells - Range_Start and Range_End. These ranges are single cells that contain an ADDRESS ref using MATCH to pick out the start and end of the column I need.
I then pass these named ranges to the formula I showed in my question but using INDIRECT to convert the cells to addresses:
=INDIRECT(Range_Start):INDEX(INDIRECT(Range_Start):INDIRECT(Range_End),COUNTA(INDIRECT(Range_Start):INDIRECT(Range_End)))
Works like a dream :-)
Related
So I'm going to eventually have 3 sheets. Sheet 1 is where I have data (numbers for a category and a name associated with it. Sheet 2 is where I pull the top 5 users for each category. Sheet 3 is where I have a leaderboard for points gained.
Right now I'm trying to work with Sheet 2 (grab the top 5 performers from each category. I'm fairly new to Excel, but after some research it seemed that XLOOKUP would be the way to go. (i'll attach screenshots below.
I'm using this formula:
=XLOOKUP(LARGE('Cases Test for Categories'!$C$18:$C$55,1),'Cases Test for Categories'!$C$18:$C$55,'Cases Test for Categories'!$A$18:$A$55)
however when using it I get all 0's.
Here's a screenshot of values I'm trying to grab from "Warranty Service Request"
and here is a screenshot when applying my formula
The solution I would want is to grab the 5 largest numbers from sheet 1 with the person name as well.
I don't think that XLOOKUP can get you anywhere near what you want but the formula below will get you one step closer.
=INDEX(List,MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0),1)
In fact, it's the explanation of that formula which will be of help. Here we go.
List is a named range, perhaps equal to your 'Cases Test for Categories'!$C$18:$C$55. The reason for using a name is obvious. It's shorter. In my test List = A2:B6, in case you want to reconstruct it. Column 1 has names, column 2 numbers.
The term INDEX(List,,2) specifies the second column of List. You can replace the '2' with a formula to specify different columns of the named range.
In fact, INDEX(List,,1) does specify the first column and INDEX(List,4,1) specifies the 4th cell in that column, and that is exactly what you see in my formula. All of MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0) just serves to find the row number in List, in this example the number 4.
Of course, LARGE(INDEX(List, ,2),1) returns the largest number in column2 of List. The '1' can be replaced by a formula, for example ROW()-1 which would return 1 if placed in row 2 and count up from there as it's copied down. Try =ROW()-1 in any cell in row 2 and copy the formula down.
MATCH([LARGEST],INDEX(List,,2),0) returns the row number where the largest was found, and that is the number we need to return the name from the first column of List.
This will work perfectly for one column and can easily be modified to work for different columns. Your question doesn't specify how you would like to arrange the 5 results from each category but the formula can be modified a little to accommodate whatever you want. What it can not do is to deal with ties. MATCH(LARGE can only find the first of several identical results.
To break ties in this sort of operation is complicated and must be done ether by helper columns in the data table or using VBA. It's definitely the topic of another question. For now I hope that it's a problem you will not have to anticipate.
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.
I have some testing data that has been run every quarter for several years.
Each table corresponds to one quarter, and has the results for four tests by office. This data is organized in Excel as follows (this is a small sample):
Using this data set, I need to fill out this summary table:
Basically, I need to look up the value in the data set that would correspond to both the row reference and column reference. For example, row reference "UK" and the column reference "Test 1A-Q217", returning "14.85" in the summary table.
I tried using an INDEX( MATCH, ( MATCH)) formula, but that didn't work. Since the tables are laid out one after another, it would just return the results of the first table instead of the reference that matched more closely further down. What would be another way to fill out the table?
My ideal way:
Use OFFSET inside a VLOOKUP to dynamically set the vlookup area. I would first modify your data set the following ways:
Change the header rows such that col A states the quarter (e.g.
"Q1-17") and the other headers just state the Test (e.g. "Test 1A").
This is not a MUST, but will make things significantly easier. If you don't want to mess with your data, you can add a col above/below yur current headers to does this for you using LEFT/RIGHT/SEARCH (see other threads for extracting sub-strings from strings)
In your output table, put test in 1 row (e.g. "Test 1A" in row 1) and date in another (e.g. Q1-17" in row 2)
Your new formula would look something like this
=VLOOKUP($A4,OFFSET($A$3:$G$14,MATCH($V1,$A$3:$A$500,0)-1,),MATCH($V$2,$A$3:$Z$3,0),0)
What is happening is that you are doing normal VLOOKUP with 2 modifications to make it more dynamic. yous set the lookup table using OFFSET and you set the column using standard MATCH approach.
You may need to make additional modifications since I have added a row to your data set.
Note: I have not tested out this formula, you may need to make minor adjustments to the formula but this should get you what you need
Alternatively, you could create named ranges for each of your data sets and have a VLOOKUP inside your main VLOOKUP that selects the correct named range to look inside of. I think this is less elegant, will take longer to set up, and and adds additional work every time you want to add another data set each quarter.
This question was asked and the answer ALMOST works for me.
THE PROBLEM
Very simply from the above dataset I wish to recreate this range but filter for only select BLOOD TYPE O.
The answer given is:
=IFERROR(INDEX(A:A,SMALL(IF(ISNUMBER(SEARCH("O",INDIRECT("$A2:$A"&COUNTA(A:A)))),ROW(INDIRECT("$A2:$A"&COUNTA(A:A))),""),ROW()-1)),"")
This works only in ROW 2. I have tried everything to get this to begin in a new row and column (I also want the data to be in a different row and column) but whenever i update the formula, nothing is returned.
ED please see this new picture:
In the image above, I place your example data set in the range C3:F13. Based on your question it sounded like you were trying to filter your list based on blood type, but I was not sure if you just wanted names, or some other combination of columns. This solution assumes you want all columns in the order they are presented. I placed the following formula in I5:
=IFERROR(INDEX($D$4:$F$13,AGGREGATE(15,6,(ROW($C$4:$C$13)-3)/($C$4:$C$13=$I$2),ROW(A1)),COLUMN(A1)),"")
In I2 is the value of the blood type you are filtering your list for.
in the formula above, adjust the ranges to suit your data range locations. The -3 in the formula is for the number of header rows before the data starts. If you have headers or other space and your first piece of data was in row 15 then you would need to change -3 to -14.
Is there any way to look up and display the latest value in a group that does not have a set range?
Here's a breakdown of a question. I am working with some data that I like to break into data groups that can be collapsed. On a weekly basis I un-collapse the group and insert a line at the bottom with the new information. I would like that latest bit of information to be automatically displayed on the top cells that is displayed when collapsed.
I have used look-up tables and I have a function that I used for testing purposes: =LOOKUP(2,1/(C5:C11<>""),C5:C11) that obtains the last cell within that designated ranged: C5-C11.
Now can I do something similar within grouped data values that have no defined range?
One way to do this is with an index function, assuming that there are no other rows of data on this worksheet other than the group that you're trying to find. Here's an example of a formula that could work for you. It assumes that your data starts in K2 and you want to have your result in K1.
=INDEX(OFFSET(K2,,,ROWS(K:K)-ROW(K2),1),MATCH(9.99999999999999E+307,
OFFSET(K2,,,ROWS(K:K)-ROW(K2),1)),1)
The offset creates an array for all cells below k1 without counting k1. The match function searches for the largest number possible, this formula assumes that you're looking for numbers. If you're looking for text, or a combination, you'll have to use a different formula by replacing the match portion with:
MATCH(REPT("z",255) 'for text
MAX(MATCH(9.99999999999999E+307,range),MATCH(REPT("z",255) 'for numbers and text
Source: http://www.techonthenet.com/excel/questions/last_value.php