If formula comparing two columns - excel-formula

Need a formula that says if the combination of information in Column 3 & 4 in the same row match the combination of Column 1 & 2 in the same row then say YES, otherwise say No. Column 5 shows what I would like to see. There is a orange in column 1 that has 2222222 in column 2 so it would show as NO where as there is a Banana in Column I that has 2222222 in column 2.
FIRST SET OF VALUES SECOND SET OF VALUES
COLUMN 1 COLUMN 2 COLUMN 3 COLUMN 4 COLUMN 5
ORANGE 11111111 ORANGE 22222222 NO
BANANA 22222222 BANANA 22222222 YES
PEAR 33333333 PEAR 55555555 NO
PEAR 44444444 WATERMELON 55555555 YES
WATERMELON 11111111 GRAPES 66666666 YES
WATERMELON 55555555 PEACH 33333333 YES
GRAPES 66666666 PLUM 44444444 NO
GRAPES 77777777 PINEAPPLE 34343434 YES
GRAPES 22222222
PEACH 33333333
PLUM 88888888
PLUM 77777777
PINEAPPLE 99999999
PINEAPPLE 12121212
PINEAPPLE 34343434
PINEAPPLE 56565656

Use COUNTIFS():
=IF(COUNTIFS(I:I,M3,J:J,N3),"Yes","No")

Related

On SQL with one-to-many merging and many as a narrowing condition

Use sqlalchemy
Parent table
id name
1 sea bass
2 Tanaka
3 Mike
4 Louis
5 Jack
Child table
id user_id pname number
1 1 Apples 2
2 1 Banana 1
3 1 Grapes 3
4 2 Apples 2
5 2 Banana 2
6 2 Grapes 1
7 3 Strawberry 5
8 3 Banana 3
9 3 Grapes 1
I want to sort by parent id with apples and number of bananas, but when I search for "parent id with apples", the search is filtered and the bananas disappear. I have searched for a way to achieve this, but have not been able to find it.
Thank you in advance for your help.
Translated with www.DeepL.com/Translator (free version)

VLOOK Excel results does not match Power Query Merge

I have Created Power query to perform VLOOK on two tables using merge.
When I Merge them using Full Outer, the result is not same as VLOOKUP Excel.
It seems that Excel VLOOKUP formula takes first instance of match and does not goes further.
Table2
Apple 2 fruit
Grapes 14 fruit
Grapes 15 fruit
Grapes 16 fruit
Banana 22 fruit
Banana 23 fruit
Banana 24 fruit
Banana 25 fruit
Table1
prod sno (VLOOKUP)
Apple 1
Grapes 14
Grapes 14
Banana 22
Banana 22
=VLOOKUP(A2,Table2[#All],2,FALSE)
let
Source = Table.NestedJoin(Table4, {"prod"}, Table2, {"prod"}, "Table2", JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"snum"}, {"Table2.snum"})
in
#"Expanded Table2"
RESULT FROM PQ FOR VLOOKUP
prod Table2.snum
Apple 1
Apple 2
Grapes 14
Grapes 15
Grapes 16
Grapes 14
Grapes 15
Grapes 16
Banana 22
Banana 22
Banana 23
Banana 23
Banana 24
Banana 24
Banana 25
Banana 25
Delete the expand step you are already using. Assuming XXX is column name from the merge step, add add column... custom column... with formula
= Table.FirstN([XXX],1)
Then right click column XXX and remove it. Expand the new column instead
That will just pick up a single result from the merge, the top row

SUMIFS excluding two criteria

I'm trying to do SUMIFS with two criteria I want to exclude.
I want to count the amount of fruit sold by all, excluding cherries sold by James.
A
B
C
Qty
Product
Salesperson
5
Apples
James
10
Apples
Jack
15
Apples
Ben
20
Bananas
Ben
15
Bananas
Jack
10
Cherries
James
5
Grapes
Ben
10
Grapes
James
15
Cherries
Jack
20
Melons
Ben
I've tried
=SUMIFS(A:A,B:B,AND(B:B"<>Cherries",C:C"<> James"))
but got an error.
=SUMIFS(A:A,B:B,"<>Cherries",C:C,"<>James")
Also does not work as it doesn't count and Cherries or anything sold by James.
From the data above I would expect 115 as my answer.
subtract the part from the whole:
=SUM(A:A)-SUMIFS(A:A,B:B,"Cherries",C:C,"James")

How to find the total length of a column value that has multiple values in different rows for another column

Is there a way to find IDs that have both Apple and Strawberry, and then find the total length? and IDs that has only Apple, and IDS that has only Strawberry?
df:
ID Fruit
0 ABC Apple <-ABC has Apple and Strawberry
1 ABC Strawberry <-ABC has Apple and Strawberry
2 EFG Apple <-EFG has Apple only
3 XYZ Apple <-XYZ has Apple and Strawberry
4 XYZ Strawberry <-XYZ has Apple and Strawberry
5 CDF Strawberry <-CDF has Strawberry
6 AAA Apple <-AAA has Apple only
Desired output:
Length of IDs that has Apple and Strawberry: 2
Length of IDs that has Apple only: 2
Length of IDs that has Strawberry: 1
Thanks!
If always all values are only Apple or Strawberry in column Fruit you can compare sets per groups and then count ID by sum of Trues values:
v = ['Apple','Strawberry']
out = df.groupby('ID')['Fruit'].apply(lambda x: set(x) == set(v)).sum()
print (out)
2
EDIT: If there is many values:
s = df.groupby('ID')['Fruit'].agg(frozenset).value_counts()
print (s)
{Apple} 2
{Strawberry, Apple} 2
{Strawberry} 1
Name: Fruit, dtype: int64
You can use pivot_table and value_counts for DataFrames (Pandas 1.1.0.):
df.pivot_table(index='ID', columns='Fruit', aggfunc='size', fill_value=0)\
.value_counts()
Output:
Apple Strawberry
1 1 2
0 2
0 1 1
Alternatively you can use:
df.groupby(['ID', 'Fruit']).size().unstack('Fruit', fill_value=0)\
.value_counts()

counting unique row values in excel

I have product list like this. I have only product name list
Apple 1
Apple 1
Apple 1
Orange 2
Orange 2
Orange 2
Mango 3
Mango 3
Pineapple 4
Pineapple 4
Pineapple 4
Pineapple 4
Pineapple 4
Pineapple 4
Avocado 5
I want to count data in this way. please help.
In B1 insert 1 and in B2 insert:
=IF(A2=A1,B1,B1+1)
And from there just fill.
Put 1 in B1 then put this formula in B2,
=if(a2<>a1, max(b$1:b1)+1, b1)
... and fill down.
Alternately just put his formula into B1,
=SUMPRODUCT(1/(COUNTIF(A$1:A1,A$1:A1)))
... and fill down.

Resources