I'm trying to create a dashboard, where upon selecting a company from a dropdown list, it will list all of the company's bankers where the data is on another worksheet tab.
So far, the Index Match formula seems to be running fine, however, it keeps on running and lists the bankers from other companies. How can I fix this?
File can be downloaded here: https://drive.google.com/file/d/1fw7yh4AEF1vx3cuG6E_1RBTrTD_k74KD/view?usp=sharing
You can try below approach by pasting below formula in cell E5:
=IFERROR(INDEX(RAW!$D$2:$D$279,SMALL(IF(RAW!$B$2:$B$279=$C$5,ROW(RAW!$D$2:$D$279)-1,10^10),ROWS($A$1:A1))),"")
This is array formula so it needs to be committed by CTRL+SHIFT+ENTER and then copy it down as much needed.
Explanation:
INDEX is retrieves the range reference from the defined GRID based on the row and column reference.
In this particular case, we intend to extract the references sequentially. This is performed by SMALL(IF(RAW!$B$2:$B$279=$C$5,ROW(RAW!$D$2:$D$279)-1,10^10),ROWS($A$1:A1))
Within this formula, first portion is the ARRAY building IF formula as below
IF(RAW!$B$2:$B$279=$C$5,ROW(RAW!$D$2:$D$279)-1,10^10) which tests cells in column B if they match criterion value. If the value matches then ROW reference is returned and if it doesn't then it returns a very large value i.e. 10^10. We subtract 1 from row reference as the data starts from row 2 so it should be (n-1) in principle. This arrangement produces an ARRAY like {1;2;3;4;5;6;7;10000000000....} for value "Acorda".
But we need to pass one element at a time to INDEX formula so this is done by SMALL(IfBasedArray,k) where k part is serially generated by ROWS($A$1:A1) which starts with 1 and increments downwards as the formula gets copied which thus enables INDEX to return desired results.
Finally, when the matches are finished then big number i.e. 10000000000 gets fed and generates an error which then is covered by IFERROR formula to return blank!
Please apply this formula to your sheet's E5 and copy down. Note that I created the named range Coms which refers to RAW!B2:B279.
=IFERROR(IF(INDEX(Coms,MATCH($C$5,Coms,0)+ROW()-ROW(E$5))=$C$5,INDEX(Coms,MATCH($C$5,Coms,0)+ROW()-ROW(E$5)),""),"")
If you prefer, the name in the formula can be replaced with the address, as you had it originally, or you define the named range to expand dynamically.
A simpler option than the 2 previous answers (doesn't require an CSE array entered formula or multiple nested INDEX/MATCHES) would be to have a couple of 'helper' cells in say G5/G6
Start Row would be =MATCH(C5,RAW!B:B,0) This finds the first row on your RAW sheet where the selected company appears
Advisor Count would be =COUNTIFS(RAW!B:B,C5) counts how many rows there are for this particular company
Then your formula in cell E5 becomes =IF(D5<=$G$6,INDEX(RAW!$D:$D,$G$5+D5-1),"") which you can drag down.
screenshot showing formulas/result
Related
In order to do some calculations on averages and differences of values in columns, I've defined a name, based on a range, but it seems to be completely going berserk:
I have a cell (D13), defined as Header_First _Answer, which contains the title of the column, and I have a value (currently being 69), which contains the number of entries, called Total_Count.
I've defined the entries of that column as another name: "All_First_Answered_Dates", defined as =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0) (start by the first entry under Header_First_Answer, take up to 69 entries, and define a range out of this).
In cell G5, I'm using that name in order to do some calculations (calculating averages), but this seems not to work (there is a #Value error).
After second comment from Rory: G5 formula and first formula evaluation result:
Formula:
=AVERAGE(IF(ISBLANK(All_First_Answered_Dates);TODAY();All_First_Answered_Dates) - All_Start_Dates)
First evaluation result:
=AVERAGE(IF(ISBLANK(#Value!);TODAY();All_First_Answered_Dates) - All_Start_Dates)
Hence, my conclusion:
After some checking I've found out that this is due to the name "All_First_Answered_Dates", which seems to be interpreted one time too many (or how do I explain this):
In different cells, I've entered the formula =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0) (which is exactly the meaning of "All_First_Answered_Dates"), and every time, using the Evaluate Formula feature, I see that the last but one result is correct: $D$14:$D$82. However, after that, another evaluation is done, turning this value into 43283 (in case the formula is entered in "J14"), 43300 (in case the formula is entered in "J15"), ..., and in case I enter this formula in a cell with row number lower than 14, I have the error value #Value (which explains the wrong result in cell G5).
If I simply put the formula =$D$14:$D$82 in any of the mentioned cells, then the content of some cells in column D are shown (which are dates, not values like 43283 or 43300).
It appears that declaring a range as =x:y, where x and y are formula results, is not working.
Does anybody know how I can define a range as a formula, which I can then use in order to define in a name?
I can imagine my explanation being quite complicated without an image, hence the attached screenshot. In there:
In cell J13, there is the formula =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0).
In cell J14, there is the same formula.
In cell K14, there is the formula =$D$14:$D$82.
For completion purposes, hereby a screenshot of the name manager, containing both mentioned names (the ones, selected in the name manager):
Edit after first comment:
The idea behind the range is the following:
1. Take the first row under Header_First_Answer, do not take any other column : OFFSET(Header_First_Answer;1;0)
2. Take the Total_Count's row under Header_First_Answer, do not take any other column : OFFSET(Header_First_Answer;Total_Count;0)
3. Define a range, based on those two cells, by putting a semicolon between them.
I was not aware of the height and width features of the Offset() worksheet function. I've implemented them, which makes the formulas much easier.
Unfortunately the problem still persists.
Thanks in advance
Dominique
I've just found the answer of what was going wrong:
The formula was meant to be an array formula. Something went wrong and while trying to debug, I accidently re-formatted the formula into a normal formula (I must have pressed "ENTER" instead of "Ctrl" + "Shift" + "ENTER") at some point.
I have re-applied array formula (using "Ctrl" + "Shift" + "ENTER"), getting a formula like:
{=AVERAGE(IF(ISBLANK(All_First_Answered_Dates);TODAY();All_First_Answered_Dates) - All_Start_Dates)}
(mind the braces {, })
Now everything is working fine.
Here's my situation
Goal: create a unique list in sheet2 based on a list with duplicates in sheet1.
What I've tried: ={IFERROR(INDEX(Sheet1!$B$2:$B$100,MATCH(0,COUNTIF($B$2:B2,Sheet1!$B$2:$B$100),0)),"")}
The issue: the formula produces the list I'm looking for, however it produces a 0 at the end of the list (e.g. B3 through B25 is correct but cell B26 has a 0). The problem is I can't figure out how to delete it. I've tried an if(0,"") statement and that doesn't work. Note, my list in Sheet1 only has about 25 total entries, however I want the formula to read to B100 to account for additional material. I did however try the formula ending exactly where my list ends and that does not produce a zero.
If anyone has any ideas, please let me know.
Thanks
That is because the blank cell at row 26 will satisfy the equation as unique:
You can add a another criterion:
IFERROR(INDEX(Sheet1!$B$2:$B$100,MATCH(1,(COUNTIF($B$2:B2,Sheet1!$B$2:$B$100)=0)*(Sheet1!$B$2:$B$100<>""),0)),"")
This is an array formula and needs to be confirmed with Ctrl-Shift-Enter.
Another method would be to make the reference data set dynamic:
=IFERROR(INDEX(Sheet1!$B$2:INDEX(Sheet1!$B:$B,MATCH("ZZZ",Sheet1!$B:$B)),MATCH(0,COUNTIF($B$2:B2,Sheet1!$B$2:INDEX(Sheet1!$B:$B,MATCH("ZZZ",Sheet1!$B:$B))),0)),"")
This will set the referenced data to the extents, and as new data is added it will automatically grow or shrink and thus never refer to a blank cell.
Use the above if the data on sheet 1 is Text if it is numbers replace both "ZZZ" with 1E+99
I have a spreadsheet that I'm importing data into. I need to find the value within a column that is closest to zero. The column contains both positive and negative values, and the value closest to zero will be used in another formula. I've found an answer using an array formula, but it will only work for a fixed range (e.g. K2:K10), and the number of records imported into my sheet will vary each time I use it.
Here's what I have so far:
=INDEX(K:K,MATCH(MIN(ABS(K:K)),ABS(K:K),0))
Is there a way to apply an array formula over an entire column and just include non-zero cells other than the column title? Or possibly just cells with numerical values? Or is it possible to control the range that it applies to?
We can dynamically find the last cell in the range by using another INDEX/MATCH formula that is not an array:
=INDEX(K:K,MATCH(1E+99,K:K))
This will find the last cell that has a number in column K.
So we now use this as the last cell in the range:
=INDEX($K$2:INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS($K$2:INDEX(K:K,MATCH(1E+99,K:K)))),ABS($K$2:INDEX(K:K,MATCH(1E+99,K:K))),0))
And now the formula is dynamic.
This formula is still an array formula and must be confirmed with Ctrl-Shift-Enter when exiting edit mode. If done correctly then Excel will put{} around the formula.
If as you pointed out there is a chance of deleting row 2 then all the K2 references will also be deleted.
In place of K2 we can use INDEX(K:K,2) It will now always look at the second row and will not error when row 2 is erased. So use this instead:
=INDEX(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K)))),ABS(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K))),0))
There is nothing wrong with the Offset() function in small amounts, but it is a volatile function. Which means that it will calculate EVERY TIME excel calculate whether the data to which it is dependent has changed or not.
For the benefit of anyone reading this post, I ran into another issue and found a way around it. Scott Craner's answer above worked well until I ran a macro that I had for that sheet, which would delete certain rows. If row 2 got deleted, the formula would give a #REF error, because it was trying to call $K$2.
My solution was to replace $K$2 with
OFFSET(K1,1,0)
Therefore, the complete formula would be:
=INDEX(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K)))),ABS(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K))),0))
And as Scott mentioned, remember to hit Ctrl-Shift-Enter to execute the array formula.
I am using a formula in Excel 2010 to display the individual with the most wins, as below:
IF($P$3="Most wins",SUM(LARGE(Wins,{1})),"FALSE")
where wins represents an array of an indefinite number of individuals.
However I would like to be able to autofill this, or similar, such that the next row displays the following:
IF($P$3="Most wins",SUM(LARGE(Wins,{2})),"FALSE")
Unfortunately I can't get the value inside the curly brackets to increment, which is causing no end off issues when the formula is going to be dragged down beyond 1,000 rows.
Is this possible, or am I using the wrong method?
=IF($P$3="Most wins",SUM(LARGE(Wins,ROW(A1))),"FALSE")
Place that in the top of your column and copy it down. As you do, the cell reference for A1 will change from A1 to A2 to A3, etc. The ROW function returns the number of the row of the cell reference.
Alternatively as pointed out in Darren's comment, you could also use ROW()-2 if you data is starting in the second row. This has the advantage if you ver deleted the 1 row or column, you will not screw up your cell references.
I am using excel to create data sets that are used in a vba application later. I am using this formula:
=INDEX(BaseData!$L$2:$L$10000;MATCH(DataSet!D5&DataSet!E5&DataSet!K5;INDEX(BaseData!$B$2:$B$10000&BaseData!$C$2:$C$10000&BaseData!$D$2:$D$10000;0);0))
usually with a range from f.ex.: A2 - A10000, because my data can be differently long and often vary in data selection.
However, this slows my excel extremely down. I switched to manual calculations, but then, when activating automatic again, my excel instance takes extremely long and often crashes.
I also tried to past some data, but when creating a new dataset, I have to pull the formula down again and sometimes through this errors occur in my data set.
Any suggestions what I can do to make the INDEX-MATCH formulas more performant?
I appreciate your replies!
UPDATE
I guess a lot of performance goes away because index-match does not select the exact range, but also counts in blank rows. How to get the exactl range with index match automatically?
As I mention in my comment above, as long as this is a 'regular' formula and not an Array Formula, you may find success simply replacing "A1:A10000" with "A:A". However barring that, you can create a cell which will calculate reference the number of rows of data which you have, and then use that cell to indirectly reference the complete column with data in it.
CALCULATING YOUR DESIRED RANGE
For the following example to work, I assume that: Column A includes an index key in the form of numbers only; Column A includes no numbers in the header and above; and that the index rows are continuous, with no breaks. Start with the following formula:
=COUNT(A:A)
If my assumptions above hold, then this will return the number of data elements in your table. Once we know where this data starts, we can use this COUNT to determine where it ends. Assume your header is in row 2. (I like to include the header so that if you insert a row beneath the header, Excel picks up that you want to include the new row in your formulas).With that in mind, this formula will create the Excel-style reference which finds the last cell in column A which has data in it:
=ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1)
Assuming 50 rows of data [which start at row 3, below the header], and all other assumptions above, this formula will return the text result "$A$53".
If you wanted to do the same thing, but instead return the full range in Column A where data exists (from the header to row 53), you could do as follows:
=ADDRESS(ROW(A2),COLUMN(A2),1,1)&":"&ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1)
This returns the text string result "$A$2:$A$53", which is a reference to the full index of unique ID values. It will automatically move around as you would generally expect if you insert any rows or columns. Now assume for your INDEX that you want to pull the same data, but for column B, instead. The formula will be exactly the same, except that where I have "COLUMN(A2)" above, replace with "COLUMN(B2)".
REFERENCING YOUR CALCULATED RANGE
So now you have the address of your proper, limited columns - but how do you actually reference those areas in a formula? By using the INDIRECT function. INDIRECT says "Evaluate some specific criteria. It will create a cell reference. Now look at that cell reference." In its simplest form, this could look like this:
=INDIRECT(A1)
Assume that A1 holds the value "B5". Indirect will pick up the value "B5", and instead of displaying "B5", it will go to B5, and pick up the value there. So to use this with the above, wrap the whole thing in the INDIRECT function. Instead of picking up the text string "$A$1:$A$53", it will actually now reference that range properly. Like so:
=INDIRECT(ADDRESS(ROW(A2),COLUMN(A2),1,1)&":"&ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1))
USING A NAMED RANGE
But that is a very long formula to have, and you won't want to use it within a specific cell for a simple INDEX/MATCH. Instead of entering these formulas in cells (although you could), I recommend you go to the Formula Ribbon -> Name Manager -> New Name. Call the name for the index of A "ID_COLUMN". Call the name for the index of "B_COLUMN" (or something more specific).
FINAL FORMULA
Now, if you wanted to make an INDEX/MATCH of your table, which automatically grows/shrinks as you change the data, your formula would look like this [this would, for example, pick the row from column B where column A has the number 100]:
=INDEX(ID_COLUMN,MATCH(100, B_COLUMN, 0))