Array formula with another array as input - excel

I'm trying to get a dynamic range to use on dropdown lists in excel, I was not able to use the traditional solutions as I'll have several lines where I need this validation, and that would need me to create a "buffer" column for each entry and I want to avoid that.
Here's my Data table:
Item
Vendor
B123
A
B123
B
B321
C
B321
D
B456
E
This starts in cell A1 and is formmated as a Table called ItemList.
Then I have the following formula on cell D1. My output is a horizontal list with the unique entries of the Item column
=TRANSPOSE(UNIQUE(ItemList[ITEM]))
Then on cell D2 I have the below:
=FILTER(ItemList[Vendor];ItemList[ITEM]=D1)
Which is then expanding the values A & B below B123. However I'd like it to also work on all the spilled range of D1.
This is my current output:
B123
B321
B456
A
B
This is my desired output:
B123
B321
B456
A
C
E
B
D
Any ideas? I tried adding D1# instead of D1 in D2 formula, but no good.

Related

Matching multiple value in excel using index and match

I used index and match to identify the values of the table and matched it. However I am facing trouble when I try to get b and c, a is matched correctly
A. B C D.
1 a b c
2 fruit1 a
3 fruit0
4 fruit3
5 fruit5 a
E F
1 fruit1 a
2 fruit0 c
3 fruit3 b
4 fruit5 a
My formula is
=Iferror(if(index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)) = b$2,index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)), ""),"")
If your data table is in E1:F4, and you are trying to look up the fruit names that appear in column A starting at A2, and place the correct letter next to them in column B, then there's no need for the IF and the sequences of MATCHes.
All you need is this, pasted into cell B2 and copied down, is this:
=IFERROR(INDEX($F$1:$F$4,(MATCH(A2,$E$1:$E$4,0))),"")
An easier approach to this is just:
=VLOOKUP(A2,$E$1:$F$4,2,FALSE)
or to be safer:
=IFERROR(VLOOKUP(A2,$E$1:$F$4,2,FALSE),"")
And if you have access to O365 Excel and the newer XLOOKUP function, you can use the following examples. XLOOKUP incorporates the "not found" result so you don't have to do a separate IFERROR. Do do it on a cell-by-cell basis as you had before, put this in B2 and copy it down:
=XLOOKUP(A2,$E$1:$E$4,$F$1:$F$4,"",0)
If you want to go one step further, you can apply the XLOOKUP as an array or "spill" formula, you change the lookup_value to be the A1:A4 and it does the rest. Place this in B2 and it will fill B2 through B5:
=XLOOKUP(A2:A5,$E$1:$E$4,$F$1:$F$4,"",0)

How to separate unique values in column and put all corresponding rows in a single row

I have a data set that looks something like this-
Item
Value
A
1
A
2
A
3
B
1
B
2
B
3
C
1
C
2
And I want to convert it to this -
Item
Value
A
1,2,3
B
1,2,3
C
1,2
Using your provided example data, and assuming a data setup like this:
In cell D2 and copied down is this formula to get unique items: =INDEX($A$2:$A$9,MATCH(0,COUNTIF(D$1:D1,$A$2:$A$9),0))
In cell E2 and copied down is this formula to get the joined values: =TEXTJOIN(",",TRUE,REPT($B$2:$B$9,$A$2:$A$9=D2))
Adjust the ranges to suit your actual data.

Identify if list contains not unique values without countif in a helper column

A B C
1 Product A 1 Error
2 Product B 1
3 Product C 2
4 Product C 2
5 Product D 1
6 Product E 1
7
8
In the table above I want to identify if the values in Column A are unique.
If there is at least one value which is not unique Error should be displayed in Cell C1.
In order to achieve this I went with helper Column B and with the following formulas:
Column B `=COUNTIF($A$1:$A$6,A2)`
Cell C1 =`IF(COUNTA($A$1:$A$6)<SUM($B$1:$B$6),"Error","OK")`
All this works fine.
Now, I am wondering if there is also way to avoid the helper column.
Basically, a formula that goes through Column A and if it identfies at least one not-unique value it should display Error in Cell C1.
use:
=IF(MAX(COUNTIF($A$1:$A$6,$A$1:$A$6))>1,"Error","OK")
This is an array formula and depending on one's version will require the confirmation of Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one has the dynamic formula UNIQUE() then:
=IF(COUNTA(UNIQUE($A$1:$A$6))<>COUNTA($A$1:$A$6),"Error","OK")
As a normal formula.
Another formula, that will work in Conditional formatting:
=SUMPRODUCT(--(MATCH($A$1:$A$6,A:A,0)<>ROW($A$1:$A$6)))>0

Get the column number of a search criteria in a defined range

I have the following Excel spreadsheet:
A B C D E F G H
1 Search Criteria: Prod.D
2 Column: 4
3 Prod.A Prod.B Prod.C Prod.D Prod.E
4
5
In Range D3:H4 I have Product A to Product E listed.
Now, I want to achieve that when I put a product name into Cell C1 I will get back the Column Number of the product in the range.
In the example above I want to search for Prod.D within the Range D3:H4 and therefore the result in Cell C2 should be 4 since the search criteria appears in the fourth column within the defined range.
What formula do I need to achieve this?
Try this formula in cell C2:
=MATCH(C1,D3:H3,0)

Formula to Return Text in the Row of Largest Number

Column A Has Text & Columns B, C & D contain numbers.
For Ex.)
A... …B C D
John 4 6 2
Dave 4 6 4
Mike 4 5 1
Bill 2 5 9
I would like a cell to return the name in column A that has the Largest Number in Column B. And if there are similar numbers, go to the next column and determine which is highest, and if that is tied go to the next column and so on.
Any help would be appreciated.
We can de-conflict ties.In E1 enter:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))
and copy down. Then in another cell enter:
=INDEX(A:A,MATCH(MAX(E:E),E:E,0))
EDIT#1
This is only good for 3 columns of numbers, but it is very easy to add additional de-confliction terms if necessary:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))+E1/(1000*MAX(E:E))
For an expandable number of rows/columns, use a helper row with the same number of columns as number columns in your data. The formulas below reference the following image (the data are in A1:G7):
B9-->=MAX(B1:B7)
C9 (fill over the remaining columns to G9)-->
=MAX(IF(MMULT(--($B1:B7=$B9:B9),--(ROW(INDIRECT("1:"&COLUMNS($B9:B9)))>0))=COLUMNS($B9:B9),C1:C7))
The following formula will give the answer (shown in A9 above):
=INDEX(A1:A7,MATCH(TRUE,(MMULT(--($B1:G7=$B9:G9),--(ROW(INDIRECT("1:"&COLUMNS($B9:G9)))>0))=COLUMNS($B9:G9)),0))
UPDATE WITH ALTERNATIVE METHOD
Using a helper column instead, again referencing the image below (the data are in A1:G7):
I1 (fill down to I7)-->
=SUM(--(MMULT(SIGN(B1:G1-$B$1:$G$7)*2^(COLUMN(G1)-COLUMN(A1:F1)),--(ROW(INDIRECT("1:"&COLUMNS(B1:G1)))>0))>0))
The following formula will give the answer (shown in J1 above):
=INDEX(A1:A7,MATCH(MAX(I1:I7),I1:I7,))
As a bonus, notice that the helper column corresponds to the order that you would get from sorting the data by each column left-to-right. In other words, you could use the helper column to perform a formula-based multi-column sort on strictly numeric data. For the last image, entering the following array formula into a range with the same dimensions as A1:G7 gives a descending sort on columns B through G:
=IF(A1:A7=A1:A7,INDEX(A1:G7,MATCH(ROW(A7)-ROW(A1:A7),I1:I7,0),))

Resources