Trying to figure this out
Say cell A1 has unique values "Car | Bike | Truck ", I would like to use Vlookup to match this to a table that has values for one of the unique values
Category Value
Shoes 1
Bike 2
Hat 3
Coat 4
Example above would return 2
There could be instances where the values dont exist in the table, which is OK. Also, I can change " | " to commas if needed, it's just how the output file currently is.
Thanks!
Consider the Array Formula:
=INDEX(D2:D5,MATCH(TRUE,ISNUMBER(SEARCH(C2:C5,A1)),0))
With data like:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
Related
I've got a few thousand rows in an excel spreadsheet, which (simplified) looks like this:
ID Category Animal Version Value
100 A Dog 1 20
100 B Cat 2 50
100 C Dog 3 50
200 A Dog 1 100
200 A Cat 2 100
300 B Cat 1 80
400 C Dog 1 80
I need to have the row with the highest/max version for each group of ids listed.
So in other words, I'd want these showing:
ID Category Animal Version Value
100 C Dog 3 50
200 A Cat 2 100
300 B Cat 1 80
400 C Dog 1 80
Is this possible?
Finding and showing the maxima/minima for grouped data with a single formula in only one cell can be done with the following formula:
=UNIQUE(FILTER(MyArray,MMULT(((ValueRange>TRANSPOSE(ValueRange))+(ValueRange=TRANSPOSE(ValueRange))-(GroupRange=TRANSPOSE(GroupRange)))*(GroupRange=TRANSPOSE(GroupRange)),SEQUENCE(ROWS(GroupRange),1,1,0))=0),FALSE,FALSE)
For an example, see this screenshot: Link
The output automatically adjusts for any number of groups in the data array.
With the operator > used in the formula, it will return the maximum. By using < it will return the minimum.
Note that the UNIQUE() function will only show distinct rows for each group maximum (see group 'Alpha' in screenshot).
If there is more than one maximum in a group and more than just the group and value column, the UNIQUE() function will show all distinct rows taking into account all columns (as can be seen for group 'Alpha' and 'Gamma' here: Link).
You can use the Advanced Filter with a formula criteria:
=D9=AGGREGATE(14,6,1/(A9=Table1[ID])*Table1[Version],1)
where D9 is the location of the first entry in the Value Column
Before applying Filter
After applying Filter
Suppose your data is in range A1:E8,
In cell A11, put in the following formula to find unique ID, drag it down until there is a #N/A error:
=INDEX($A$2:$A$8,MATCH(0,INDEX(COUNTIF($A$10:A10,$A$2:$A$8),0),0))
In cell B11, put in the following formula and drag it down to find the latest Version:
=AGGREGATE(14,6,$D$2:$D$8/($A$2:$A$8=A11),1)
In cell C11, D11 and E11, put in the following formulas respectively and drag them down to find the corresponding Category, Animal and Value:
=INDEX($B$2:$B$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
=INDEX($C$2:$C$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
=INDEX($E$2:$E$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
Let me know if there is any question. Cheers :)
For a list without duplicates you can put this in cell G2 ARRAY-FORMULA: CTRL + SHIFT + ENTER
=IFERROR(INDEX(A:A,MATCH(1,(COUNTIF(G$1:G2,A$1:A$99)=0)*(A$1:A$99<>""),0)),"")
This gives you a list with unique ID's. Now you can use the max formula to get the max version number of each ID. ARRAY-FORMULA: CTRL + SHIFT + ENTER
=MAX(IF($A$2:$A$2000=G3,$D$2:$D$2000,0))
The rest can be done with INDEX/MATCH formulas.
I have a table of data that include a name column and two numeric columns. Example:
A B C
Fred 4 2
Sam 3 6
George 1 7
I'm wanting to retrieve the name in column A for the largest sum of columns B and C. In the example above, I would want "Sam" because 3+6 is greater than any of the other sums.
I know I could create a hidden column (D) that's filed with
=SUM(B2,C2)
and do something like this:
=INDEX(A:A,MATCH(MAX(D:D),D:D,0))
but I'd rather avoid the hidden column, if possible. Is there a way to perform an index-match based on the sum of two cells?
Use the array formula:
=INDEX(A:A,MATCH(MAX((B:B)+(C:C)),(B:B)+(C:C),0))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
(Note the appearance of braces in the formula bar)
I have a sheet of data and want to run a count on the values in Raw data with the following criteria:
If the value in raw data is repeated FOR EXAMPLE London No1 and London No1 AUTO only to be counted once, but if the value in raw data is London No1, London No2 and London No1 Auto then only to count 2 (to count London No1 and London No2 only).
Raw data
London No1
London No2
London No1 Auto
London No2 Auto
Bristol No1 Auto
Cardiff No1
Cardiff No2
In this example Result should be: London - 2, Bristol - 1, Cardiff - 2.
This solution uses only one "working column" and assumes the following:
The list of Raw Data is located at A1:A16 (adjust as required)
The Raw Data records follow this syntax City NoX string all separated by a blank space. X is one digit number (do let me know if there will be larger numbers in order to adjust the formula)
(All ranges include header)
With the list of results located in the same worksheet at B1:D16
(adjust as required) and including the following fields:
Site: List of Cities to count in Raw Data
Unique Record: Used to list unique "clean" city records before counting. Enter this FormulaArray in D2 and copy till last record
(Formulas Array are entered by pressing [Ctrl] + [Shift] + [Enter]
simultaneously)
=IFERROR( INDEX(
MID( $A$2:$A$16, 1, 2 + FIND( "No", $A$2:$A$16 )),
MATCH( 0, COUNTIF( D$1:D1,
MID( $A$2:$A$16, 1, 2 + FIND( "No", $A$2:$A$16 ))), 0 ) * 1 ), "" )
Result Count: Enter this FormulaArray in C1 and copy till last record
=IF( EXACT( $B2, "" ), "",
IFERROR( COUNTIF( $D$2:$D$16, $B2&"*" ), "" ))
Assumptions
So if I understand your clarifications, you have a list of cities, and each city might have a different "No" on it. ie: some will be "No1", "No2", etc. Also, some might have "Auto" on it. There are sometimes duplicates, ie: "London No1" might appear twice. Also, whether or not the word "Auto" appears, it will be a duplicate if that "No" already appears. ie: "London No1" is identical to "London No1 Auto".
Helper Columns
To count how many unique instances of each city there are, I propose you use a helper column which first removes the word auto, and then only displays itself if it is not a duplicate of a prior entry.
With your data in column A, starting at A2, enter this formula in B2 and copy down:
=IF(ISERROR(MATCH(TRIM(SUBSTITUTE(A2,"Auto","")),$B$1:$B1,0)),TRIM(SUBSTITUTE(A2,"Auto","")),"")
This formula works as follows:
-First it takes the text in A2, and it replaces the word "Auto" with "". Then it TRIMS the resulting text, which means it earases any trailing spaces at the end. It takes that trimmed text, and attempts to MATCH it with the previous rows in column B. If it doesn't find a match, it results in an error. IF it ISERROR, then it shows the text (because it's the first time it has appeared). Otherwise, it shows "".
Array Formula
Now that you have this in column B, we will use Array Formulas to count how many unique instances of each city appeared. An Array Formula is a specific formula which calculates many time over an entire range, instead of just one cell. It then returns an Array of results, which we need to collapse into a single answer. For example:
=SUM(IF(A1:A5>5,B1:B5,""))
[Confirmed with CTRL + SHIFT + ENTER instead of just ENTER]
In the above example, the Array Formula will check if each individual cell from A1:A5 is a number larger than 5. If it is, it will return the cell from column B in that row. It then takes all resulting answers from column B (where A was > 5), and SUMS them to a single number.
In this case, the Array Formula will be as follows [Starting in D5 in your image and moved one column to the right, immediately to the right of the first city name, and copied down for each city; I am assuming that your raw data goes from A2:A100]:
=SUM(--NOT(ISERROR(SEARCH(C5,$B$2:$B$100))))
Confirm this formula with CTRL + SHIFT + ENTER instead of just ENTER. Then copy down for each city name in column C.
It works by attempting to search each unique value in column B for the city name shown in that row of column C. Wherever it the city name is not present, ISERROR returns TRUE for that element of column B. Then NOT turns all TRUEs to FALSEs and vice versa. Then the -- tells excel to convert TRUE and FALSE to their numerical equivalents [1 and 0, respectively]. So we will have a TRUE [AKA 1] for each match, and FALSE [AKA 0] for everything else. The sum of all 1's is the number of matches of that city name in your list of unique entries.
Friends,
I need to list all the unique entities (items) in a Excel spreadsheet, how to?
E.g.
**List1**
1
1
1.1
2
a
a
aa
b
c
c
And I need a certain function that returns:
**Entities**
1
1.1
2
a
aa
b
c
Then I can count the occurence of each entity (using COUNTIF function).
With data in column A, in B2 enter the array formula:
=IFERROR(INDEX($A$2:$A$11,MATCH(0,COUNTIF($B$1:B1,$A$2:$A$11),0)),"")
In C2 enter:
=COUNTIF($A$2:$A$11,B2)
and copy down.
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
You can also apply pivot to your list to identify uniqueness. One you have identified the unique list, you can apply count if formula.
I have 3 columns of data. Col A contains Names, Col B contains a client ID, Col C contains a date.
I'm trying to figure out how to write a formula that will find the top 2 and top 3 instances of a specific Name in Col A and client ID in Col B and return the value in Col C.
Trying to avoid using VBA, but not sure if this is doable.
So for example data looks like this and I would want to return that Sam dealt with Client ABC the 2nd time around on 12/16.
Sam ABC 12/3
Adam XYZ 12/5
John DEF 12/9
Sam ABC 12/16
Adam HIJ 12/18
Assuming
your headers are in A1:C1
your data starts from A3 (yes, not A2)
You enter the name in G2 & Client ID in G3 & you want the list of
dates starting from G5
Enter these formula/values:
A2: =G2
B2: =G3
C2: =0
G5:
=IFERROR(INDEX(($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500),MATCH(0,COUNTIF($G$4:G4,($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500)),0)),"End")
(Formula in G5 is an array formula; confirm this with Ctrl+Shift+Enter)
Drag the formula in G5 down until you see 'End'
Value in cell G5 will always be 0 or '1/0' based on your formatting.
The list of dates corresponding to the name & client ID combination will start from G6.
Let me see if I understood your need. Correct me if I'm wrong.
You want to be able to inform a Name and a Client ID and have Excel tell you the last 3 occurrences of that combination?
By "top 2 and top 3 instances of a specific name" I'm assuming you mean the top 2 and 3 dates found for that specific name and ID.
If so, try this:
Supposing you have your example data table starting at Cell A1 and ending at Cell C6 (including column headers) and that you'll enter the name in F1 and Client ID on F2
A B C
1 Name Client ID Date
2 Sam ABC 12/3
3 Adam XYZ 12/5
4 John DEF 12/9
5 Sam ABC 12/16
6 Adam HIJ 12/18
Type this formula where you want to return the date of the last occurrence:
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),1),"-")
This should be entered as an Array Formula, so don't forget to press CTRL + SHIFT + ENTER or it'll not work.
To bring the 2nd last occurrence on another cell, just copy and paste the formula and change the number 1 to 2 (as indicated below):
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),2),"-")
If you typed 'Sam' on F1 and 'ABC' on F2, this formula would return '12/16' as the last occurrence, '12/3' as the 2nd last occurrence and a dash (-) as the 3rd last occurrence, since there isn't one.
Of course, you'll have to adjust the ranges and other cell references accordingly in your real data set.
Hope this helps.