Excel - Match Value and Get Value of Other Column - excel

I am trying to match 2 values on a table and if match, display the value from other column. Example is as below,
A B C D E F
ABC 1 WWE 5 output (1 FROM ABC) output (10 FROM ABC)
GHI 2 XYY 1
XXY 3 ABC 10
May I know how to do it? Can it be done in Excel

Use an INDEX/MATCH formula, for example in column E:
=INDEX(B:B,MATCH($A1,A:A,0))
And in column F:
=INDEX(D:D,MATCH($A1,C:C,0))
I'd usually wrap these in an IFERROR(,"") function to tidy up any errors. These formulas are based on you searching for the value in column A each time, if you want to search for a string instead simply replace $A1 with "ABC".

Related

How to find and replace from a List in Excel

Not using VBA but just simple excel, can anyone help me find a solution to this problem? Would greatly appreciate it!
I have a list of Names in Sheet 1 like below
-
A
1
sp_abc_Rick
2
sp_abc_Jabba_the
3
sp_abc_Dany
4
sp_random_Rick
5
sp_random_Jabba_the
6
sp_random_Dany
7
sp_constant
8
sp_ripley_art_Dany
9
sp_ripley_art_Jabba_the
10
sp_wakeup
I have a list of Mapping Table in Sheet 2 like below
-
A
B
1
Rick
Morty
2
Jabba_the
Hutt
3
Dany
Dragon
I wish to have a result in Sheet 1, in column B, like below
-
A
B
1
sp_abc_Rick
sp_abc_Morty
2
sp_abc_Jabba_the
sp_abc_Hutt
3
sp_abc_Dany
sp_abc_Dragon
4
sp_random_Rick
sp_random_Morty
5
sp_random_Jabba_the
sp_random_Hutt
6
sp_random_Dany
sp_random_Dragon
7
sp_constant
sp_constant
8
sp_ripley_art_Dany
sp_ripley_art_Dragon
9
sp_ripley_art_Jabba_the
sp_ripley_art_Hutt
10
sp_wakeup
sp_wakeup
To give you a context of the number of rows. Sheet 1 will be bigger with more than 1000 rows. Sheet 2 (Mapping Table) is constant set of rows. Currently it is about 100 rows.
You can use a formula like shown below using LOOKUP(), SEARCH() with SUBSTITUTE()
• Formula used in cell B1
=IFERROR(SUBSTITUTE(A1,LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$D$1:$D$3),
LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$E$1:$E$3)),A1)
There you go. There may have other better solution. This is what I got.
All in column B.
=IFERROR(CONCAT(MID(A1,1,MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)-1),INDIRECT(CONCAT("sheet2!b", MATCH(MID(A1, MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE), LEN(A1)), Sheet2!$A$1:Sheet2!$A$300, 0)))),A1)
Break down is as follow;
Let's start put things from Column C onward.
Column C, to find the index of the first capital letter from the text.
ref: http://dailydoseofexcel.com/archives/2007/02/21/find-position-of-first-capital-letter-in-a-string/
=MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)
Column D, cut the name part by using upper case letter index from column C, sp_abc_Jabba_the -> Jabba_the
=MID(A1, C1, LEN(A1))
Column E, search row number from Sheet2 by matching Column D's name with Sheet 2's Column A, this will get matching row number from Sheet2.
=MATCH(D1, Sheet2!$A$1:Sheet2!$A$300, 0)
Column F, get Sheet2's Column B value by the row number from Column E.
=INDIRECT(CONCAT("sheet2!b", E1))
Column G,
Cut "sp_abc_" from "sp_abc_Rick"
Concat "sp_abc_" with Column F's "Morty".
If there is any error, use Column A value as default.
. <- this dot is intentional. please ignore.
=IFERROR(CONCAT(MID(A1,1,C1-1),F1),A1)
Try:
Formula in B1:
=BYROW(A1:A10,LAMBDA(a,LET(b,TEXTBEFORE(a&"|","_"&A12:A14&"|",-1),IFERROR(CONCAT(IF(b&"_"&A12:A14=a,b&"_"&B12:B14,"")),a))))
The concatenation with a "|" would assert we only replace values when at the exact end of the input. Just in case there would be a stray (for example) 'Rick' somewhere before the end.

Ignore text values in subtotal function

Excel-Sheet:
A B C D E
1 1.200
2 Product A 500
3 Product B 400
4 Product C OK
5 Product D #NA
6 Product E 300
7
8
In the above table I have list of products in Column A and some data about the products in Column B.
In Cell B1 I want to calculated the subtotal of Column B using =SUBTOTAL(9,B2:B6).
However, now I have the issue that Column B not only consists of numbers.
It can also have the data type text (OK, NA). Therefore, the result in Cell B1 currently is #NA.
Is there any kind of formula that I could use so only the number data is considered and the result is 1.200 as in the table above?
Please note:
This function =AGGREGATE(9,6,B2:B6) won't help me because I want to filter the list later on so I need to go with the SUBTOTAL.
Use 7 as the second criterion in AGGREGATE instead of 6 as it will also exclude hidden rows:
=AGGREGATE(9,7,B2:B6)
You can solve this, combining the Excel worksheet functions =Value() and =IfERROR():
The function =Value() gives the value of a number, and in case of text it gives an error.
=IfError() can be used to give 0 in that case.
So, imagine you have following situation:
Column A Column B Column C
1 =Value(A1) =IfError(B1;0)
3.5 =Value(A2) =IfError(B2;0)
AB =Value(A3) =IfError(B3;0)
abc10 =Value(A4) =IfError(B4;0)
This gives following results:
Column A Column B Column C
1 1 1
3.5 3.5 3.5
AB #Value 0
abc10 #Value 0
You can simply take the sum of column C.
So this is based on the summary in B1.
=SUM(IF(ISERROR(B2:B6),"",B2:B6))
You need to push Ctrl+Shft+Enter for this to work.
Hope it helps.

Excel function for SELECT DISTINCT.. WHERE

I am trying to filter data in an Excel sheet using functions based on multiple columns. For example, if column B has '*ABC*', I want to count the number of unique values in column A.
A B
--- ---
1 xyz
1 abc
2 ABCD
3 AB
4 ABCE
4 qwe
4 ABC
5 xyzABC
For the above example, I am expecting the answer 3, since the number of unique values in A matching '*ABC*' are 2,4 and 5 => 3 unique values.
Index Match only returns the first result and I am not able to figure out how to use Countifs to join both these conditions - unique and wildcard match.
As an Array Formula:
=SUM(IF(ISNUMBER(SEARCH("ABC",B1:B8)),1/COUNTIFS(A1:A8,A1:A8,B1:B8,"*ABC*")))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Find duplicates with a suffix in excel and keep results

I have a spreadsheet with a list of items in one column (A) and in column C shows the total sold. I'm trying to find all the items within column A.
The issue is, some items are the same, only they have a suffix, mostly separated by a -. The values in column C would be different as well.
Example:
ABC = 5
ABC-123 = 3
ABC-543 = 2
I'm looking to identify only 123 and then combine all the values, so that it will show ABC and 10 as the total.
I've looked around how to remove the duplicate suffix, but have so far failed to find a method when trying to add the total values.
Many thanks
do you mean the data you have looks like this:
column A column B column C
ABC 5
ABC-123 3
ABC-543 2
if so, you can select column A then go to data then text to columns then delimited select other by putting - sign, next and finish.
result must be:
column A column B column C
ABC 5
ABC 123 3
ABC 543 2
then you can =sumifs(C:C;A:A;"ABC") (keep in mind that column B must be empty)
if you have ABC-123 = 3 in the same cell as a text, then you can do:
=IF(SEARCH("ABC";F3);RIGHT(F3;LEN(F3)-FIND("=";F3)-1);"")
where F3 is equal to ABC-123 = 3 The formula above searches fo ABC and gives you a value after = sign, no matter how long this value is. If there is no ABC it will return an error.
if there is no need to look for ABC then just use:
=RIGHT(F3;LEN(F3)-FIND("=";F3)-1)
I hope this helps. I cannot comment, so ask if you have questions.
Best - AB

COUNTIFS based on complex criteria

A B C
1 M 2233 1R
2 M 1122 1
3 B 3311 0R
4 S 3333 0
5 M 0033 1R
From the following table, I would like to count every row in column C that contains an "R" but only if column A contains "M" and the last two characters of column B are "33". So the output I would like to get is 2 (C1+C5). Note that column B is formatted as text.
So far, I have tried COUNTIFS(A1:A5,"=M",B1:B5,MID(B1:B5,3,2)="33",C3:C5,"=*R") as an array formula without luck.
I know one problem is that MID(B1:B5,3,2)="33" isn't being treated as an array formula but I'm at a loss on how to fix it.
Any takers?
You can use this I think:
=COUNTIFS(C1:C5,"*R*",A1:A5,"M",B1:B5,"*33")
Using wildcards * to indicate where values can be different.
The following gives the result you're after:
=COUNTIFS(A1:A5,"=M",B1:B5,"=*33",C1:C5,"=*R*")
This counts the rows from 1 to 5 where A is 'M', B ends with '33' and C contains 'R'. Note that your original formula wasn't helped by only counting C3:C5.
What's crucial here is how column B is formatted - wildcards don't work with numeric values so you can only use COUNTIFS if column B is numeric, i.e. this formula:
=COUNTIFS(A1:A5,"M",B1:B5,"??33",C1:C5,"*R")
if that doesn't work because column B is numeric then try SUMPRODUCT like this
=SUMPRODUCT((A1:A5="M")*(RIGHT(B1:B5,2)="33")*(RIGHT(C1:C5)="R"))
That doesn't explicitly ensure that column B has 4 characters with 33 as the last two (as COUNTIFS does), merely that the last 2 characters are 33 - if you need to check that there are 4 characters use this version:
=SUMPRODUCT((A1:A5="M")*(RIGHT(B1:B5,2)="33")*(RIGHT(C1:C5)="R")*(LEN(B1:B5)=4))

Resources