Count unique values from columnA if adjacent columnB meets a criteria and is not equal to a second criteria - excel

This is my first post and hopefully I can explain this issue clearly.
Assuming the following raw excel table:
ColumnA ColumnB ColumnC
1 W A
1 E A
1 W B
1 E C
1 E D
1 E E
1 W E
1 E F
Count of unique E in ColumnB 5
Count of unique W in ColumnB 3
Task:
1) In counting unique values in ColumnC, count unique values that have a value of E in ColumnB.
2) In counting unique values in ColumnC, count unique values that have a value of W in ColumnB, taking into consideration that if an item in ColumnC has both E and W in ColumnB, it should only be counted for assumption 1 above. Only items in ColumnC that have only W in ColumnB should be included in this count.
As shown in my results, the count for items that have E in ColumnB is 5 which is correct. However, the count for items that have W in ColumnB is returning 3, but it should only return 1 because {1, W, B} is the only row where ColumnC item B has only a W in ColumnB.
The excel formula I have used for both counts are below:
Count for E
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",IF($B$2:$B$9="E",MATCH($C$2:$C$9,$C$2:$C$9,0))),ROW($C$2:$C$9)-ROW($C$2)+1),1))
Count for W
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",IF($B$2:$B$9="W",MATCH($C$2:$C$9,$C$2:$C$9,0))),ROW($C$2:$C$9)-ROW($C$2)+1),1))
Note the formula needs to be entered with Ctrl+Shift+Enter
How can I count for W and exclude rows from ColumnC that have both E and W in ColumnB?
Thanks in advance.

Try using this formula:
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",IF($B$2:$B$9="W",IF(COUNTIFS($A$2:$A$9,1,$B$2:$B$9,"E",$C$2:$C$9,$C$2:$C$9)=0,MATCH($C$2:$C$9,$C$2:$C$9,0)))),ROW($C$2:$C$9)-ROW($C$2)+1),1))
also using CTRL+SHIFT+ENTER
The additional COUNTIFS function gives you the extra functionality you need because that checks if there are additional rows with "E" against the relevant column C values
...or an alternative approach would be to count all different values from column C (assuming 1 in column A), and just subtract your "Count for E", so if that "Count for E" formula is in B12 use this array formula
=SUM(IF(FREQUENCY(IF($A$2:$A$9="1",MATCH($C$2:$C$9,$C$2:$C$9,0)),ROW($C$2:$C$9)-ROW($C$2)+1),1))-B12

Related

Is there a way to have column O pull values from column F is J through L match A through C

I have column A as city code, B as Origin City,St , C as city code, D as Destination city,St. I then similar date in I through L with Carriers that haul those lanes in N. If a row in the I through L match a row in A through D I need the value of F place in the O column in the corresponding row.
I am trying to paste an image of the Excel grid, but I need column O to pull the value from column F from the row that has the values from A to D that match the data in a row in I to L.
Expected Result in Grid
You can use a combination of index() with match()
So, to fill Column O, this should work:
=INDEX(F$40:F$60,MATCH(I40&K40,G$40:G$60,0))
I have assumed that you can add a helper column in G, which is =A40&C40 dragged down.
I have also assumed that the combination of the two numbers in cols A & C are unique when combined.
If that is not the case then you will need to add col B, so the helper column becomes =A4&B40&C40 and the match will be I40&J40&K40.
Tested this on 3 values, as you don't give data I can get to.

scan Excel column based on another column value

I want to check one entire column with value in another column and then assign a value in another column value to matching row cell.
Eg-
A B C D
1 10 X
2 3 Y
3 2 Z
4 11 K
What I want to do is take one value at a time from column A eg 1 and then scan through Column B if matches the Column A (value 1) then assign x to that row under D. eg if we check A3 ( value 2) with column B and found 2 is on B4 then D4 = Z. Like this I want to check all values in column in A against column B assign relevant vale from column C to Column D
How can I do this, can someone please help me.
Thanks.
Try:
= IFERROR(INDEX($C$2:$C$5,MATCH(A3,$B$2:$B$5,0)),"no match")
See below.
Try:
=IFERROR(VLOOKUP(A1,$B$1:$C$5,2,0),"")

Deducting numbers based on value in a different column

I have a C column with several rows containing numbers. I have another E Column with rankings.
I would like a formula that will automatically change the number in a 3rd column G based on the ranking in E column
So,
If the ranking is 2 in E the number in G is number in column C
minus 1
If the ranking is 1 the number in E the number in G is
number in column C minus 2
Any other ranking the number remains the
same.
Example -
C E G
19 2 18
12 1 10
15 3 15
Put below formula in G column -
=IF(E1=1,C1-2,IF(E1=2,C1-1,C1))
Above formula is for row 1. Adjust row value according to your need.
Explanation -
Check if E column contains 1, then subtract 2 from C column
Else, check if E column contains 2, then subtract 1 from C
column
Else, G column is same as C column

Excel if vaules of 2 columns match then take the difference of another two columns

I have 4 columns of data. I want to match the values of two of the columns then if take the difference of two other columns if the first two match. So it's accounts and amounts.
Example. If col A matches Col C take the difference of Col B and Col D and Out it in Col E
Col A Col B Col C Col D Col E
1234 $100 1234 $100 $0
1235 $120 1235 $150 $-30
1236 $150 1237 $150
1238 $130
=IF(A1=B1,C1-D1,)
A1 and B1 are cell references to values you are comparing, and C1 and D1 are cell references to the values you are trying to take the difference of. If you'd like to have the cell be blank instead of 0, add "" after the last comma.
Assuming first data row to be A2:E2, Please put below mentioned formula in cell E2
=IF(A2=C2,B2-D2)
Similarly you can do reverse action by like if it is not then add them or put 0 or blank by "" or subtract B2 from D2 by below given options.
=IF(A2=C2,B2-D2,B2+D2)
=IF(A2=C2,B2-D2,0)
=IF(A2=C2,B2-D2,"")
=IF(A2=C2,B2-D2,D2-B2)
Hope this would help!

Lookup a value that matches a key in one column then apply that as a key to return a value from a third column

I have values in columns G and N that have the same values, but not in the same order, so if column G and N matches, then return column L to column A. I am getting the wrong values from column L in column A.
What other information is needed besides formula below?
=IFERROR(VLOOKUP(N2,$G$2:$N$413,6,FALSE),"")
Col a Col b Col G Col L Col M Col N
ID CoID Items ItemsID ParentID Items1
45 1 Apple 45 1 Apple
Since you are trying to find the ColumnL value in the same row as you find the ColumnN value I’d suggest an INDEX MATCH combination – similar to VLOOKUP but more powerful (eg can ‘look to the left’, which VLOOKUP can’t).
=IFERROR(INDEX(L:L,MATCH(G2,N:N,0)),"")
MATCH looks for the position where G2 is found in ColumnN so that is the row number for the ColumnL value you want returned.

Resources