In Excel, I want to convert the table on the top (Initial data) into the one at the bottom (Desired output).
I want to group the items in the second row by the first row, and then generate one column per unique value of the first row and list the items of the corresponding group in that column.
Is there a way to do that without manually copying cells?
Table: Initial data
Fruit
Banana
Fruit
Apple
Fruit
Grape
Vegetable
Spinach
Vegetable
Eggplant
Table: Desired output
Fruit
Vegetable
Banane
Spinach
Apple
Eggplant
Grape
If you have access to the UNIQUE and FILTER functions (Excel 365), you could accomplish this as follows.
Assuming your data is in A1:B5. In D1 enter:
=TRANSPOSE(UNIQUE($A$1:$A$5))
This will get you the unique values from the cells in A in D1:E1. Then in D2 enter:
=FILTER($B$1:$B$5,$A$1:$A$5=D1)
And drag to the right.
I.e. you do this:
Result:
Related
The problem is simple to understand. I just need to know a formula that will help find a way to fetch the top 2 rows of each group in an excel sheet.
The below example is grouped by column 1.
Example
Given Table:
Column 1
Column 2
Apple
A102012
Apple
A102013
Apple
A102014
Banana
A102015
Banana
A102016
Banana
A102017
Coconut
A102017
Result:
Column 1
Column 2
Apple
A102012
Apple
A102013
Banana
A102015
Banana
A102016
Coconut
A102017
Try:
Formula in D1:
=REDUCE(A1:B1,UNIQUE(A2:A8),LAMBDA(a,b,VSTACK(a,TAKE(FILTER(A2:B8,A2:A8=b),2))))
To mimic this for Google Sheets:
=REDUCE(A1:B1,UNIQUE(A2:A8),LAMBDA(a,b,{a;QUERY(A2:B8,"Where A='"&b&"' limit 2")}))
A much slower alternative is:
=FILTER(A:B,INDEX(COUNTIFS(A:A,A:A,ROW(A:A),"<="&ROW(A:A)))<3)
A faster method than countifs not using most recent additions to Excel, if it can be assumed that data are pre-sorted:
=LET(count,COUNTA(A:A),Column1,A2:INDEX(A:A,count),Column12,A2:INDEX(B:B,count),FILTER(Column12,SCAN(0,SEQUENCE(count-1),LAMBDA(a,c,IF(c=1,1,IF(INDEX(Column1,c)=INDEX(Column1,c-1),a+1,1))))<=2))
or in Google Sheets:
=ArrayFormula(lambda(Column12,filter(Column12,SCAN(0,SEQUENCE(rows(Column12)),LAMBDA(a,c,IF(c=1,1,IF(INDEX(Column12,c,1)=INDEX(Column12,c-1,1),a+1,1))))<=2))(filter(A2:B,A2:A<>"")))
If you have Excel 365 you can also use this formula
=LET(rank,MAP(tblData[value],tblData[fruit],
LAMBDA(v,f,SUMPRODUCT((tblData[fruit]=f)*(v<tblData[value]))+1)),
FILTER(tblData,rank<=2))
The MAP function calculates the rank of each row within its group.
Then we can filter by that list.
I have 4 columns in excel. Date, Apple, Banana and Oranges. I have a different sheet where I have a header called "Today's Production" Under the header I have Banana, Apple and Oranges listed. How do I populate these fields
Screenshot added
If the first cell of your table were in A1, for the bananas column, you can just use something along the lines of
=SUMIFS(B1:B10,A1:A10,TODAY())
Then for apples, you would adjust your B column to C, and for oranges, adjust B to D
I want to grab some array depend on specific string.
Name Qty Request
Fruits Apples 54 100
Fruits Bananas 43 100
Fruits Lemons 41 100
Fruits Pears 13 50
Vegetable Cucumber 5 50
Vegetable Kale 10 50
I want to make some table on other sheet and become like this
Pick Type Vegetable
Cucumber 5 50
Kale 10 50
Which Vegetable text is dropdown
I know how to update dropdown and get array B6:D7 using MATCH but I don't know show them as a table.
How about a Pivot Table?
As with many questions here, Excel already has inbuilt functionality
for this. In this case it is actually better to use, than the formulas, since > the table will auto-update itself, even if there's new
item added.
Select the data you want to work with
Insert Tab -> Pivot Table or alternatively press Alt + N + V
Edit the Pivot Table settings (by default on right) to match your criteria. In your case:
After filtering for Vegetables, it provides the expected result:
Put this in G2 then fill right and down.
=IFERROR(INDEX(B:B, AGGREGATE(15, 7, ROW($2:$9)/($A$2:$A$9=$H$1), ROW(1:1))), TEXT(,))
H2
=INDEX($C:$C,MATCH($G2,$B:$B,0))
Drag down.
I2
=INDEX($D:$D,MATCH($G2,$B:$B,0))
Drag down
I have a data set, let's say like this:
Item Name
Apple
Carrot
Carrot
Pear
Pear
Pineapple
Radish
Orange
Orange
Pineapple
Pineapple
and I also have a LIST like this:
List of Items:
Apple
Orange
Pineapple
How to write a formula that will count how many rows in the dataset have a value that is NOT a part of the list? ... so in this case 5...
You could just take the number which are in the list away from the total:-
=COUNTA($A$2:$A$20)-SUMPRODUCT(COUNTIF($A$2:$A$20,$B$2:$B$20))
assuming data items in column A and list in column B.
You need to create a named range of the list.
Mark your list of items and in the "name box" write LIST.
Now if the long list is in column A, then in column B write the following formula:
=IFERROR(VLOOKUP(A1;LIST;1;FALSE);1)
It will find the match in the LIST if it excists, if not write "1".
=COUNTIFS(rng,"<>Apple",rng,"<>Orange",rng,"<>Pineapple")
Assuming your named range for the long column is rng.
Obviously this works best if your short list is very short.
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")