How to populate columns with data in Excel using unique row combinations between two columns - excel

This seems like it should be easy enough to do, but I can't seem to figure it out or find a tutorial.
I have two columns containing values. I would like the unique column combinations to repeat in another set of columns, and count the instances.
COLUMN A COLUMN B COLUMN C COLUMN D COLUMN E
John Apples John Apples 2
John Apples John Bananas 1
John Bananas Sara Apples 1
Sara Apples Sara Kiwi 1
Sara Kiwi Mike Carrots 2
Mike Carrots Mike Kiwi 1
Mike Carrots Apples 2
Mike Kiwi Carrots 1
Apples Kiwi 1
Apples
Carrots
Kiwi
I was able to transfer the unique values from one column to another using INDEX and MATCH, but can't get it to work with two columns.
This tutorial shows what I am looking for, but I'd like the second set of data to stay in a column, and not transpose into rows. https://www.extendoffice.com/documents/excel/3358-excel-transpose-unique-values.html

Try following this short animated screen capture finishing with the following formula in E2.
=COUNTIFS(A:A, IF(LEN(C2), C2, ""), B:B, D2)

What you describe is called a Pivot Table. Drag Name and Fruit into the rows area and Fruit again into the Values area to have it counted. Pivot tables can have different layouts, i.e. with repeating labels, or in compact format.

Related

Google sheets, adding a value to a cell based on the contents of another

This may be delving in to scripting territory rather than formula, but I was wondering if it's possible to use google sheets to add values to a cell based on the contents of another? For example, If I had a sheet arranged like the following:
Column A|Column B|Column C|Column D
Apples Oranges Grapes
Tomatoes Grapes Oranges
Melons Apples Tomatoes
Grapes Lemons Apples
And then I had another section that had
Column G|Column H
Apples 1
Tomates 2
Oranges 3
Grapes 4
Melons 5
Lemons 6
Is there a formula that will let me populate the contents of column D by reading columns A - C on each row and adding the values set on column H? Making Column D read something like 8, 9, 8 etc?
I hope this question makes sense, thanks and apologies for the shoddy formatting!
=SUMPRODUCT(IFERROR(VLOOKUP(A2:C2,G:H,2,0)))
For google-spreadsheets
Please try this single-formula solution:
=mmult(filter(VLOOKUP(A:C,G:H,2,0),A:A<>""),ArrayFormula(transpose(sign(column(A:C)))))
Paste it in D1.
Here's a sample file of sum with arrayFormula.

Excel COUNTIFS multiple and sequential criteria

Column A has: Apples Oranges Pears Bananas Mangos multiple times and in random orders.
Column C has: Red Orange Yellow Blue Purple corresponding to column A multiple times and in random orders.
I am looking for a formula which counts or sums all instances where Pears immediately follow Apples (i.e. the row below Apples) AND Pears are also Orange
I can return Apples and Pears and even Pears that are Orange but I cannot figure out how to return instances of Pears that are Orange which immediately follow Apples
Use COUNTIFS() with ranges of the same size that are offset:
=COUNTIFS(A$1:A$1040000,"Apples",A$2:A$1040001,"Pear",C$2:C$1040001,"Orange")

Count of unique values in multiple columns

What I need is probably best described in an example. It's a bit different from the group functionality and also the PivotTable in Excel, because I want it to show up in the data row itself (and not off to the side or below, etc.). Given a table like:
Fruit Color Farmer
Banana Yellow Smith
Banana Yellow Smith
Apple Yellow James
Apple Yellow James
Apple Green Smith
Banana Yellow James
I want to take the first two columns and give the count of rows that have the same values (regardless of the values in the other columns). So for my example, I would get:
Fruit Color Count Farmer
Banana Yellow 3 Smith
Banana Yellow 3 Smith
Apple Yellow 2 James
Apple Yellow 2 James
Apple Green 1 Smith
Banana Yellow 3 James
My preference would be an Excel formula (or even a built in function) as opposed to VBA.
Assuming Fruit is in A1, please try in C2 (having made room for it):
=COUNTIFS(A:A,A2,B:B,B2)
and copy down to suit.

Excel: match value from an array and return cell value from the same row

I have some data in excel worksheet1 in this form:
person1 person2 person3 score
dave sarah jill 4
brandon hank 3
And in worksheet2 I have a column of people listed alphabetically, like this:
person score
alex
brandon
dave
hank
jill
sarah
I'd like to obtain each person's score from worksheet1 (with blanks for those who are absent):
person score
alex
brandon 3
dave 4
hank 3
jill 4
sarah 4
I've looked into functions like find, match, lookup, vlookup, but it seems like I will need something more complicated.
Assuming:
Each person can only ever occur once in the source data
The source data occupies the range A1:D3 (with headers in row 1)
The first person's name for which you wish to return a result is in G2
then this formula in H2:
=IF(COUNTIF($A$2:$C$3,G2),INDEX($D$2:$D$3,SUMPRODUCT(($A$2:$C$3=G2)*(ROW($A$2:$C$3)-MIN(ROW($A$2:$C$3))+1))),"")
Copy down to give equivalent results for names in H3, H4, etc.
Regards

Multiple vlookups in one cell

Ok I have two vlookups that both search from the same array but with different criterias.The first vlookup would search for the Price category. The second vlookup would seek the type of product.
This is an example array:
ID Price Type
1 Banana Fruit
2 Apple Fruit
3 Orange Fruit
4 Corn Flakes Cereal
5 Monster Energy Drink
The syntax would be:
Search for the first vlookup, if there is no results, try to search for the second vlookup.
If the first or second vlookup is true, then return value ID.
I have already made the vlookups but I have no idea how to combine both in one cell
Edit: Vlookups
=Vlookup(A2,E4:G8,2,0)
=Vlookup(B2,E4:G8,2,0)
And the lists:
A column B column
List 1 List 2
Banana Hardware
Carrot Vegetable
Orange Chocolate
Mango Candy
Fruit
It may be as simple as this:
=IFERROR(Vlookup(A2,E4:G8,2,0),Vlookup(B2,E4:G8,2,0))
Try to find one, if it fails try the other.
This formula returns corressponding ID if found value from A2 or B2 in ranges F4:F8 or G4:G8 respectively, or "not found in both columns" if both values not found:
=IFERROR(INDEX(E4:E8,IFERROR(MATCH(A2,F4:F8,0),MATCH(B2,G4:G8,0))),"not found in both columns")

Resources