How to Assign row numbers based on row values - Excel - excel

In the bellow excel data sheet, the values in the third column are manually entered. I would need a formula to automate this.
TYPE | CATEGORY | Expected_Value
fruits | apple | 1
fruits | apple | 2
fruits | apple | 3
fruits | bananna | 1
fruits | bananna | 2
fruits | mango | 1
fruits | mango | 2
fruits | mango | 3
fruits | mango | 4
fruits | mango | 5
Expected_Value represents the n-th duplicate of a given (TYPE, CATEGORY) couple.
Could someone help?

You need to use COUNTIF with an absolute reference and a relative reference. If your Category column spanned from B2 to B12 you could use this:
=COUNTIF($B$2:B2,B2)

Related

Excel formul to count Table Range using month from date text

I have an excel workbook where I am trying to count the number of apples in a named table. The workbook has multle sheets each named Jan, Feb, Mar, etc. with a corresponding table range of the same name.
My main worksheet has a list of months as columns and fruit as rows, I want to use a countif or suitable function to count the number of each fruit per month using the column heading as the worksheet portion of the formula.
This is what I have tried, this works, but has to be manually coded for each month, i would prefer it be more dynamic.
=COUNTIF(JAN[Labels],$A2)
Note: A2 contains the word apple
I have tried to get the month from the column date but it doesnt work
=COUNTIF(TEXT(E25,"mmm")[Labels],$A2)
This is roughly what the "master" table should look like (for clarity)
| | Jan-20 | Feb-20 | Mar-20 | .... |
| Apple | 4 | 3 | 5 | ... |
| Pear | 5 | 4 | 9 | ... |
EDIT:
Just to assist with anyone trying to help, this is roughly what a table on another sheet will look like:
| invoice | labels|
| 12535 | Apple |
| 12536 | Pear |
| 12537 | Apple |
This table would be a named table of Jan or Feb, etc.
Please try this:-
=COUNTIF(INDIRECT(TEXT(G2,"mmm")),"A")
G2 contains a proper date.
Here is a variation of the above where column 2 of the table is specified as the range to count in.
=COUNTIF(INDEX(INDIRECT(TEXT(G2,"mmm")),0,2),"B")
If you must use column captions to identify the column I would suggest MATCH to find it.
OK, so I found an answer, combining the above answer by Variatus with an additional new row.
| A | B | C | D |
1| | Jan-20 | Feb-20 | Mar-20 |
2| |JAN[Labels]|FEB[Labels]|MAR[Labels]| <- =UPPER(TEXT(B1,"MMM"))&"[Labels]"
3|Apple | 5 | 7 | 3 | <- =COUNTIF(INDIRECT(B$2),$A3)
4|Pear | 7 | 2 | 9 |
5|Orange| 1 | 3 | 3 |
So formula in B2 makes an uppercase text value of the month from B1 plus the column name Labels.
The formula in B3 (and down) counts the number of instances of the fruit from the named table & column shown in B2.

How to do VLOOKUP with a list of values

I have two sheet in excel.
In sheet2 I have a table with these fields:
NAME, SURNAME, CITY, AGE
In sheet1 I have to set field CITY and I want that table under this field will be with all the rows from sheet2 with selected CITY.
If I do a VLOOKUP I obioubsly get only first row of table.
Example:
A | B | C | D
NAME | SURNAME | CITY | AGE
Alex | Green | Rome | 18
Max | Brown | Rome | 21
Mary | White | Milan | 33
George | Violet | Rome | 27
In sheet 1 I have
A | B | C | D
CITY | Rome
NAME | SURNAME | CITY | AGE
VLOOKUP| VLOOKUP | VLOOKUP | VLOOKUP
VLOOKUP| VLOOKUP | VLOOKUP | VLOOKUP
VLOOKUP = VLOOKUP($B$2;Sheet2!A:D;1;0) -->
I wanted ALEX, MAX, GEORGE; I have ALEX, ALEX, ALEX
How can I do this without macros?
Thank you
For a simple data configuration like your sample pu this in Sheet1!A3 and fill both right and down,
=INDEX(Sheet2!A:A,AGGREGATE(15,6,ROW($2:$9)/(Sheet2!$C$2:$C$9=$B$1),ROW(1:1)))
For more complicated data configurations and retrievals put this in Sheet1!A3 and fill right and down,
=INDEX(Sheet2!$A:$D, AGGREGATE(15, 7, ROW($2:$9)/(Sheet2!$C$2:$C$9=$B$1), ROW(1:1)), MATCH(A$2, Sheet2!$1:$1, 0))
Use an IFERROR function 'wrapper' to avoid displaying worksheet errors when you run out of data to retrieve.

How to populate columns using values from multiple rows of another sheet (Excel)

I'm not sure what to search for this.
Basically, say I have a sheet that looks like this:
A | apple | 1
A | aardvark | 1
A | alternate | 3
B | bear | 2
B | banana | 4
C | candy | 3
C | carnivore | 2
and I want to copy values into another sheet so that it looks like this:
A | apple | 1 | aardvark | 1 | alternate | 3
B | bear | 2 | banana | 4 | |
C | candy | 3 | carnivore | 2 | |
I know there's the lookup function, but I'm not sure how to make it select the first, second, third etc. instance of what's being referenced.
Thanks in advance for any help.
For the screenshot below, use the following formulas:
E2: =IFERROR(INDEX($A$1:$A$8,MATCH(E1,$A$1:$A$8,0)+COUNTIF($A$1:$A$8,E1)),"")
F2:
=IF(INT(COLUMNS($F$1:F$1)/2)<COUNTIF($A$2:$A$8,$E2),INDEX($B$2:$B$8,MATCH($E2,$A$2:$A$8,0)+INT(COLUMNS($F$1:F$1)/2)),"")
G2:
=IF(INT(COLUMNS($G$1:G$1)/2)<COUNTIF($A$2:$A$8,$E2),INDEX($C$2:$C$8,MATCH($E2,$A$2:$A$8,0)+INT(COLUMNS($G$1:G$1)/2)),"")
Select F2 and G2, and fill to the right as far as you need, then fill the entire table down as far as you need.

Excel: count items from A and sum up value from B if identical

I want to do something very similar to what's been asked and answered here, although I don't want to have duplicates: Find count of items in column and add the values from another column
Basically, I have a column A with duplicated names, and different values associated in column B. In column C I want the name and in column D the summed up value. The problem with SUMIF is that it will show me several time the name and the summed up values, while I want to see it only once.
To make it more clear, here's the result I'm looking for:
A | B | C | D
------------+----------+-----------+---------
Name | Value | Name | Sum
------------+----------+-----------+---------
Potatoes | 9 | Potatoes | 13
Tomatoes | 4 | Tomatoes | 11
Carrots | 1 | Carrots | 16
Potatoes | 4 | Eggs | 5
Eggs | 5 | |
Tomatoes | 7 | |

Compare unique values with multiple columns and return the most recent

--------------------------------------------------
| X | A | B | C | D |
--------------------------------------------------
| 1 | Fruit | List | Date | Condition |
--------------------------------------------------
| 2 | Banana | Banana | 02/05/2010 | Good |
--------------------------------------------------
| 3 | Tomato | Banana | 02/05/2014 | Excellent |
--------------------------------------------------
| 4 | Orange | Banana | 02/05/2011 | Bad |
--------------------------------------------------
I would like to compare one-by-one the items in column A with column B, then return what's in column D for the most recent date in column C for that item.
E.g.: For "Banana" (A2) - Result = Excellent
I tried some INDEX with MATCH, but I can't get the correspondent MAX value.
Thanks
This is an array formula. Enter it in E2 by holding down ctrl-shift while hitting enter. Excel will put curly braces {...} around the formula:
=IF(COUNTIF(List,A2),INDEX(Condition,MATCH(MAX((A2=List)*Date),(A2=List)*Date,0)),"")
List, Condition, and Date are named ranges corresponding to the appropriate columns. eg: B2:b7, C2:c7, D2:d7.
This screenshot is based on your original post, as edited by me before you edited it your way:

Resources