Sum of values excluding rows with duplicate criteria - excel

I'm certain this has a simple solution but I can't find it!
Problem
I need to sum the values in COL B while excluding all but the first instance of the corresponding criteria in COL A, which may contain duplicate values.
Example Data
Record
Count
AA
1
BB
2
AA
1
CC
4
DD
7
Unique Record Count: 14
Attempted Solution
I have messing with SUMIF or SUMPRODUCT but haven't been able to work out how to also include the first instance of the corresponding value for COL A. Whatever build of Excel I have doesn't have the function =UNIQUE().

Formula in D6 is:
=SUMPRODUCT(AVERAGEIF(A2:A6;A2:A6&"";B2:B6)/COUNTIF(A2:A6;A2:A6))
Notice this will work only if all values assigned to a Record are all the same always.

You could use a helper column to get the summable values. E.g., in column C:
=IF(COUNTIF($A$2:$A2,A2)>1,0,B2)
And then do a SUM(C:C)
Example Data
Record
Count
Countable
AA
1
1
BB
2
2
AA
1
0
CC
4
4
DD
7
7

Related

Checking if pair of values exists in pair of columns?

I am attempting to find in Excel whether a unique pair of values exists across two columns in a separate spreadsheet. For example:
Array 1
1 - A
2 - B
3 - A
4 - C
Array 2
1 D
2 E
2 B
3 C
I would like the column next to 2, B to return "TRUE", and all other columns to return "FALSE", as 2B exists in Array 2 but none of the other pairds do.
I've tried surfing Stack Overflow for this problem as I felt it would be a very common lookup but surprisingly have had no luck so far. VLookups have given some results but they stop at the first pair. For example let's say we had Array 3:
Array 2
1 D
2 E
2 B
4 C
Now both 2B and 4C in Array 1 should return trues.
Formula in C1:
=COUNTIFS(D:D,A1,E:E,B1)>0
Array one in Column A
Array two in Column B
Paste this XLookup in Column C1, then drag formula down to C4. The corresponding values that match will be listed next to the values from Column A if they exist in Column B.
=XLOOKUP(A1,B$1:B$4,B$1:B$4,"",0,1)

A function that will lookup a reference

Before I get started thanks for taking your time and helping.
This is what my worksheet looks like:
Row # B C D E F
2 1 Product 1 B2 B3 B4
3 2
4 6
5 1 Product 2 B5 B6
6 5
7 4 Product 3 B7
I was trying to follow this formula: (The best answer one or green check mark) return values from multiple matching rows
I got all the way to the =IFERROR(INDIRECT(lookups!H5),"") but can not get this to work.
What I am tying to do is order the numbers in Column B to go to the right of the product. Which I was able to get the column it is in (B) and the row number it is in (B2). I would like to change the value (B2) to the number that is there.
I would like it to look like this:
Row # C D E F
2 Product 1 1 2 6
3
4
5 Product 2 1 5
6
7 Product 3 4
If someone could help explain this to me or find a better way that would be great.
Not sure what is to happen to columnB but if you replace B with "="B throughout columns D:F then select each of these in turn and apply Text to Columns with Tab as the delimiter the 'cell references' convert to formulae referring to the values in B. If you want to delete columnB copy D:F and Paste Special, Values over the top.

EXCEL match 2 columns against each other

I have two columns of data, they look something like this:
A B C D
1 2 SOME RECORD
2 6 SOME RECORD
3 10 SOME RECORD
4
5
6
7
8
9
10
So basically column A is a list of indices, where some of them appear in column C with corresponding records saved in column D. Column B is currently empty, and what I want to do is if say index 2 appears in both column A and column C (they matches), then put the record beside C2 in the cell B2. So essentially I want it to look like this:
A B C D
1 2 SOME RECORD
2 SOME RECORD 6 SOME RECORD
3 10 SOME RECORD
4
5
6 SOME RECORD
7
8
9
10 SOME RECORD
Can someone help please?!! Thanks!!!
UPDATE: I tried this and it doesn't work. The data in column D is calculated using a UDF and is refreshing every 1 second. The VLOOKUP function fails even though I can see the 2 indices are the same!! Is it because of the format of the cell or column? I.e. does vlookup compare data type as well?
Assuming your data in A starts from A1 - put in B1 the following and autofill:
=IFERROR(VLOOKUP($A1,$C:$D,2,0),"")
This includes handling of missing values.
You'll want this:
B1=VLOOKUP(A1, C:D, 2, FALSE)
This will look up the value in column A within the array spanning columns C and D. It will give you the value found in the second column (D). FALSE makes it an exact match, otherwise you might get 2 and 20 matching because hey, they're kind of similar...

Merge unique values if another cell matches

Merge all unique values if another cell matches. I already know how to merge cells but now some information is double. So what I would like to achieve is the following:
if column A has the same name, then all values given in column B for
that name must be given only ONCE in a new column.
My data has a row names and a row mode, for example (Row 1 is header)
A B
2 Brenda a
3 Brenda a
4 Joey a
5 Joey b
So I want:
E
2 a
3
4 a,b
5
I already did merge the modes in column 3:
=IF(A1<>A2;B2;C1&","&B2)
So I get in this example:
C
2 a
3 a,a
4 a
5 a,b
Then, I already did that only the first record get the additional modes in column 4:
=IF(A1=A2;"";INDEX(Sheet1!$C:$C;COUNTIF(Sheet1!$A:$A;$A2)+MATCH($A2;Sheet1!$A:$A;0) -1))
So I get in this example
D
2 a,a
3
4 a,b
5
Now I need a column that only uniques values are given for each name. So in this example:
E
2 a
3
4 a,b
5
If I am understanding how your data is structured, try this:
Add a new column, say column G for ease of explanation, that concatenates the name and mode in each row. So, cell G2="Brendaa", G3="Brendaa", G4="Joeya", G5="Joeyb", etc.
In your merge step you will test whether the current value in the cell for this column matches any previous values in the column: If no, you do the merge; if yes, you don't.
Your merge formula would change to something like the following:
=IF(A1<>A2,B2,IF(ISERROR(VLOOKUP(G2,G$1:G1,1,0)),C1&","&B2,""))
Then you would the next step as before.

Sum of columns whose header appears in a lookup table

So i have the main data table:
ColA ColB ColC ColD
aa 1 0 1
bb 1 2 2
cc 1 2 3
Row aa, bb, cc, etc. The total number of rows shouldn't be larger than a couple of hundred .
A second sheet\collumn has a table that list only the relevant column's helper, adaptable on the fly:
Helper
ColB
ColD
The search helper tells the functions which columns i should use in the search.
The idea is to sum all values from columns that are refered in the Helper table and that match the unique identifier in "ColA".
So the result would, using the above Helper table:
Identifier aa, would return 2.
Identifier BB, would return 3.
Identifier CC, would return 4.
Any idea how to do it.
You can do this with VLOOKUP, IF and SUM:
IF(VLOOKUP(C1,$H1:$H99,1)=C1, SUM(C2:C99), "")
Enter this formula with Control+Shift+Enter to make it an array formula.
=SUM(($A$2:$A$4="aa")*((($B$2:$B$4)*NOT(ISNA(MATCH($B$1,rngHelper,FALSE))))+(($C$2:$C$4)*NOT(ISNA(MATCH($C$1,rngHelper,FALSE))))+(($D$2:$D$4)*NOT(ISNA(MATCH($D$1,rngHelper,FALSE))))))

Resources