I need to extract one unique list of names based on one criteria. So far, so good. However, I also need the formula to look in the correct sheet when extracting this list. Here is my formula so far:
IFERROR(INDEX(Indirect(B$2&"!$B$2:$B$30");MATCH(0;IF(ISBLANK(Indirect(B$2&"!$B$2:$B$30");COUNTIF(E$4:$E4;Indirect(B$2&"!$B$2:$B$30"));"")
My Indirect(B$2 refers to my drop down list of my departments. Hence, each department name corresponds with one sheet name. All data available that I want to extract is thus in the range $B$2:$B$30 in the desired sheet. I am not able to see why this formula fails. Apparently, I have too many arguments, but I struggle to find out where?
Edit:
Found the problem after taking a walk...! Turned out I had too few arguments. Here is the working formula:
IFERROR(INDEX(INDIRECT(B$2&"!$A$3:$A$30");MATCH(0;IF(ISBLANK(INDIRECT(B$2&"!$A$3:$A$30"));"";COUNTIF(E$4:$E4;INDIRECT(B$2&"!$A$3:$A$30")));0));"")
The observant reader may notice that I changed my array from B2:B30 to A2:A30, where my list of names actually where placed.
Related
I have an understanding of how index/match can be used to create a unique list of items. I'm trying to create a unique list of items in a specific category and that is presenting a challenge to me.
For instance, say I have:
INDEX SPY
INDEX SPX
GOLD GLD
GOLD JNUG
GOLD GLD
INDEX SPY
and I want to extract only the unique GOLD values from the list. The output should be: GLD, JNUG.
I wrote a separate array formula to check if the left column is GOLD then output the symbol from the right column but the problem I'm having is that whatever I set for false ends up looking like it's part of the list to the index/match formula.
I was thinking that maybe there's a way to remove all zero-value array elements before exposing it to index/match but I'm out of my league here. Any suggestions on how to get the job done efficiently would be appreciated. Thank you!
Let's assume your data is in A1:B6. With UNIQUE and FILTER this is pretty easy now (Excel 2021+). Use the following in one cell, and it will spill:
=UNIQUE(FILTER($B$1:$B$6,$A$1:$A$6="GOLD"))
In earlier versions, it's a bit more work. You can use the following array formula (Ctrl+Shift+Enter to enter). Here entered into cell D3:
=IFERROR(INDEX($B$1:$B$6,MATCH(0,IF("GOLD"=$A$1:$A$6,COUNTIF($D$2:D2,$B$1:$B$6),""),0)),"")
You drag this formula down until you reach empty cells (the IFERROR() wrapper converts the #N/As that appear after all unique values have been found into ""). The "magic" is here done by IF("GOLD"=$A$1:$A$6,COUNTIF($D$2:D2,$B$1:$B$6), supplying INDEX() with new rows only for those rows that contain "GOLD" in $A$1:$A$6.
A truncated version of my data is in the form shown in the screenshot below: three columns of 5 unique names. The names appear in any order and in any position but never repeat in a single row.
My goal is to create an array that contains the number of times Adam appears in each row. I can fill down the formula=countif(A2:C2,$I$2) in a new column, or if I write the array manually for each row, it looks like:
={countif(A2:C2,$I$2);countif(A3:C3,$I$2);countif(A4:C4,$I$2);countif(A5:C5,$I$2);countif(A6:C6,$I$2)}
Where cell I2 contains "Adam". Of course, this is not feasible for large data sets.
I know that arrays are effectively cells turned into ranges, but my main issue is that the cell I'm trying to transform already references a range, and I don't know how to tell the software to apply the countif down each row (i.e. I intuitively would like to do something like countif((A2:C2):(A99:C99),"Adam") but understand that's not how spreadsheets work).
My goal is ultimately to perform some operations on the corresponding array but I think I'm comfortable enough with that once I can get the array formula I'm looking for.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IF(A2:C="Adam", 1, 0), {1;1;1})))
Excel Screenshot
Excel Screenshot with Formulas
I have attached photos to show an idea of what I am trying to do. Basically, I have a very large list of features that are shared between certain groups. I want to use a drop down list of the features, and then have a formula that will output the group that has the lowest cost of that feature along with the cost of that feature within the group.
(Also you will see that I purposefully ignore zero values. I do this because not every group has a certain feature and those cells default to zero).
I figured out how to get the cost of the feature to output, but I'm having trouble getting to output the group name. I am assuming there will be an array formula to do this, but I am just starting to learn those and I'm having trouble with this one.
Well you could always use the same approach you used to pull in the value, by pulling in the index of the column heading that matches the computed min, and using an offset function to match on the right row:
=+INDEX($B$1:$D$1,MATCH($B$10,OFFSET($B$1:$D$1,MATCH($A$7,$A$2:$A$4,0),0),0))
The thing is, I'm not sure how you would want to handle ties, if 2 vendors had the same price, this would match the first one in the list.
I am currently trying to use some excel formulas like "Index"/"Max"/"If" with multiple criteria. This means I want to lookup all values in A2:I2 and search them in my second table in A8:A20. At the same time I want to lookup the maximum in C8:C20 and for the entry that
1) matches A2:A20 and 2) has the highest value in C2:C20 I want to get the value of the "Result" column be displayed in I7, which is "D".
After trying multiple variations with Index/Vlookup/Max/If etc. I cannot find any formula for this problem to handle multiple matching criteria within arrays.
Perhaps is there any VBA solution to loop through both tables and get the result displayed below?
P.S. As this is only a small part of my worksheet it is not efficient to use one Index formula for each cell trying to match my second table. It would be great to work with two arrays matching each others values.
Using your provided sample, in result cell I7 use this formula: =MAX(INDEX((A8:A20=A2:I2)*C8:C20,))
I'm trying to setup a formula that will return the contents of an related cell (my related cell is on another sheet) from the smallest 2 results in an array. This is what I'm using right now.
=INDEX('Sheet1'!$A$40:'Sheet1'!$A$167,MATCH(SMALL(F1:F128,1),F1:F128,0),1)
And
=INDEX('Sheet1'!$A$40:'Sheet1:!$A$167,MATCH(SMALL(F1:F128,2),F1:F128,0),1)
The problem I've run into is twofold.
First, if there are multiple lowest results I get whichever one appears first in the array for both entries.
Second, if the second lowest result is duplicated but the first is not I get whichever one shows up on the list first, but any subsequent duplicates are ignored. I would like to be able to display the names associated with the duplicated scores.
You will have to adjust the k parameter of the SMALL function to raise the k according to duplicates. The COUNTIF function should be sufficient for this. Once all occurrences of the top two scores are retrieved, standard 'lookup multiple values' formulas can be applied. Retrieving successive row positions with the AGGREGATE¹ function and passing those into an INDEX of the names works well.
The formulas in H2:I2 are,
=IF(SMALL(F$40:F$167, ROW(1:1))<=SMALL(F$40:F$167, 1+COUNTIF(F$40:F$167, MIN(F$40:F$167))), SMALL(F$40:F$167, ROW(1:1)), "") '◄ H2
=IF(LEN(H40), INDEX(A$40:A$167, AGGREGATE(15, 6, ROW($1:$128)/(F$40:F$167=H40), COUNTIF(H$40:H40, H40))), "") '◄ I2
Fill down as necessary. The scores are designed to terminate after the last second place so it would be a good idea to fill down several rows more than is immediately necessary for future duplicates.
¹ The AGGREGATE function was introduced with Excel 2010². It is not available in earlier versions.
² Related article for pre-xl2010 functions - see Multiple Ranked Returns from INDEX().
The following formula will do what I think you want:
=IF(OR(ROW(1:1)=1,COUNTIF($E$1:$E1,INDEX(Sheet1!$A$40:$A$167,MATCH(SMALL($F$1:$F$128,ROW(1:1)),$F$1:$F$128,0)))>0,ROW(1:1)=2),INDEX(Sheet1!$A$40:$A$167,MATCH(1,INDEX(($F$1:$F$128=SMALL($F$1:$F$128,ROW(1:1)))*(COUNTIF($E$1:$E1,Sheet1!$A$40:$A$167)=0),),0)),"")
NOTE:
This is an array formula and must be confirmed with Ctrl-Shift-Enter.
There are two references $E$1:$E1. This formula assumes that it will be entered in E2 and copied down. If it is going in a different column Change these two references. It must go in the second row or it will through a circular reference.
What it will do
If there is a tie for first place it will only list those teams that are tied for first.
If there is only one first place but multiple tied for second places it will list all those in second.
So make sure you copy the formula down far enough to cover all possible ties. It will put "" in any that do not fill, so err on the high side.
To get the Scores use this simple formula, I put mine in Column F:
=IF(E2<>"",SMALL($F$1:$F$128,ROW(1:1)),"")
Again change the E reference to the column you use for the output.
I did a small test: