I want to count the occurrence of values in column "b" based on column "a" value. I am not sure how to do this in excel.
E.g.
A | B | C
abc | 123 | True
abc | 321 | False
abc | 123 | True
xyz | 987 | True
xyz | 987 | True
qwe | 567 | False
qwe | 765 | False
basically I am trying to see if column b value is repeated for each array of values in column a.
So, D2 counts how many and E2 shows true / false as per your column C.
I prefer to use array formulas for these sort of things.
=ARRAYFORMULA(SUM(IF($A$2:$A$8=A2,IF($B$2:$B$8=B2,1))))
Related
I have a table that looks the following:
| A | B | C |
| 40 | 1 | 1 |
| 180 | 2 | 2 |
| 34 | 1 |
| 2345 | 3 |
| 23 | 1 |
| 1 | 2 |
| 4354 | 3 |
| 2 | 2 |
| 343 | 4 |
| 2 | 2 |
| 45 | 1 |
| 23 | 1 |
| 4556 | 3 |
I want to get the sum of all fields in A where B is neither 1 nor 2 or any other value from colum C. This column contains the values of B where values from A should not be considered for the sum.
I do not know which values B might contain, those values are random and could grow larger, I just wanted to make the example small. My current solution is
{=SUMIF(B1:B13,C1:C2,A1:A13)}
so i can set the lines that should be excluded from the sum in column C. Unfortunately, the current solution does not solve my problem but something different -- it sums up the corresponding entries by value in C. My preferred solution would look something like
=SUMIF(B1:B13,"<>{1, 2}",A1:A13)
=SUMIF(B1:B13,"<>"&C1:C2,A1:A13)
if that were possible (it isn't). I would like to have:
a field (with a list, for example) or column where i can put in the values of B that I do not want to be part of the sum over A.
a method that works with Open Office as well as Excel. I prefer an OO solution.
You could use an array formula so that you can multiply each value in A with a condition. That condition can be any valid Excel formula, so, for instance, you could use MATCH to test if the B value occurs in C:
=SUM((A1:A13)*ISNA(MATCH(B1:B13,$C:$C,0)))
The ISNA function returns TRUE when the match fails, which in a multiplication is used as a numerical value 1. FALSE will make the product 0.
Make sure to enter this as an array formula with Ctrl+Shift+Enter
I have this question that puzzles me. Two columns of unique text entries in a worksheet all having a number next to each of them.
How can I compare the values for each pair of text and find the ones where the associated numbers are NOT the same.
Not even sure how the output would be. Maybe using Conditional Formatting highlighting the value in the first column where the match in the second one is different???
Thank you for your time.
Let's have some sample table.
+-----+---+-------+---+------------------------------------+
| A | B | C | D | =VLOOKUP(C1;ALL_VALUES;2;FALSE)=D1 |
+-----+---+-------+---+------------------------------------+
| abc | 1 | fasfa | 4 | #N/A |
+-----+---+-------+---+------------------------------------+
| aa | 2 | abc | 1 | TRUE |
+-----+---+-------+---+------------------------------------+
| dd | 3 | dd | 2 | FALSE |
+-----+---+-------+---+------------------------------------+
Where ALL_VALUES is named range of you table (here A1:D3). Formula returns TRUE when match is found, else it return False Or #N/A(You can transform #N/A by IfError function). Then you can filter the result in table based on this or you conditional formatting... Depends on what suits you better ;)
I'm trying to create a sumifs formula that sums cells for which the header contains a specified string (eg, "EC"), but I want it to return "NA" or error if any of THOSE cells contains NA (missing data).
My dataframe is somewhat like this:
ID | EC1 | INH2 | EC3
A | 100 | 200 | 100
B | 200 | 100 | NA
C | 200 | NA | 100
Ideal totals would look like this:
ID | ECtot | INHtot
A | 200 | 200
B | NA | 100
C | 300 | NA
Formula 1 I have tried:
=sumif([#headers][df], "*STRING*", [#df])
Actual: =SUMIF(Table1[[#Headers],[1.EC.N]:[75.TM.I]],"*EC*",Table1[#[1.EC.N]:[75.TM.I]])
Result: This sums all columns containing the string as though NA = 0; I need it to return an error or NA if any column containing the string also contains NA.
Example Result:
ID | ECtot | INHtot
A | 200 | 200
B | 200 | 100
C | 300 | NA
Formula 2:
=if(countblank([#df})=0, sumif([#headers][df], "*STRING*", [#df]))
Actual: =IF(COUNTBLANK(Table1[#[1.EC.N]:[75.TM.I]])=0, SUMIFS(Table1[#[1.EC.N]:[75.TM.I]],Table1[[#Headers],[1.EC.N]:[75.TM.I]],"*Inh*"))
Result: This returns FALSE if any cell in the entire row contains NA, not just those with the string, else returns correct sum.
Example Result:
ID | ECtot | INHtot
A | 200 | 200
B | NA | NA
C | NA | NA
Anyone have any ideas how to consolidate these 2 issues? Otherwise I'll have to sum these manually, but that involves human error (75 columns).
Also open to solutions involving R, if anyone knows any.
Thanks!
Answered my own question. Easy solution, use formula #1, and make all NA's -9999 (since values cannot be negative in this case). Then replace all sums that are negative with NA.
I have a list of id numbers for people that now have to have a new id. Shown below, in excel, I put the old id's and the new id's into the sheet next to each other. So old ID: 111 actually is ID: 123 and so on. I have a list of id's that need to be changed (Change This ID) and I would like the new changed ID to go into the result column. So, Instead of manually going through and changing them, is there a way to have a function do this for me? It would look at what is in the "Change This ID" column and see 444, then would go to the "Old ID" column and find 444, then go the the "New ID" column in the same row and find 101, then put that into the "Result ID" column. Then would go to the next line and do 333 and so on.
Old ID | New Id | Change This Id| Result Id| Name | Address |
-------------------------------------------
111 | 123 | 444 | 101 |
222 | 456 | 333 | 789 |
333 | 789 | 111 | 123 |
444 | 101 | ... | ... |
555 | 334 | ... | ... |
... | ... |
You can use the VLOOKUP function and write a formula to look up the New ID for the Id's that need to be changed.
A | B | C | D | E | F |
1 Old ID | New Id | Change This Id| Result Id| Name | Address |
-------------------------------------------------------------
2 111 | 123 | 444 | 101 |
3 222 | 456 | 333 | 789 |
4 333 | 789 | 111 | 123 |
5 444 | 101 | ... | ... |
6 555 | 334 | ... | ... |
... | ... |
Therefore, for the above data set, with the Row Numbers (1, 2, etc.) and the Column Names (A, B, etc.), you can write a formula in cell D1 as follows:
=VLOOKUP(C2,A:B,2,FALSE)
There are probably some Id's that did not change. To avoid getting an error for these Id's and just copy them over, you can wrap the VLOOKUP formula inside the IFERROR function (thanks to #Jeeped for the idea, see comments below), as follows:
=IFERROR(VLOOKUP(C2, A:B, 2, FALSE), C2)
Once you have the formula working in cell D1, you can use the Auto Fill feature to populate all the new Id's in Column D.
References:
VLOOKUP function on Microsoft Office Reference
IFERROR function on Microsoft Office Reference
Auto fill on Microsoft Office Reference
Given a column A of 100 names and another B of numbers, where column C contains a subset of those numbers how might I populate column D with the matching name? A match is where the names in A and D are next to the same number. For example, A, B and C are inputs and D the desired output:
____A______B_______C_______D____
1 |Larry | 11111 | 22222 | Bob |
2 |Bob | 22222 | 44444 | Steve |
3 |Mike | 33333 | 55555 | Jim |
4 |Steve | 44444 | | |
5 |Jim | 55555 | | |
Please try in D1 and copied down to suit:
=INDEX(A:A,MATCH(C1,B:B,0))
Not quite sure if this is what you are looking for, but a Vlookup function should help you greatly. I used a helper column to link C1 = A1, C2=A2 and so on. You can hide this column if you need to. You can then use the formula shown below in cell E1 and drag it down. As you put numbers in column D, the name will automatically fill in column E with the matching code.