I want to check A1:A10 whether they are repeated themselves in A1:A10.
I know i can use this formula in B1 to B10.
Is it possible to simplify it by one formula?
=sumproduct(($a$1:$a$10=A1)*1>1)
=sumproduct(($a$1:$a$10=A1:A10)*1>1) ???
Yes you could try:
Formula in B1:
=SUMPRODUCT((COUNTIF(A1:A10,A1:A10)>1)*(1/COUNTIF(A1:A10,A1:A10)))
In this case there are two values that are repeated/have duplicates; Test3 and Test4.
In case your goal was only to count ALL rows that have duplicates (repeated values), you can use =SUMPRODUCT((COUNTIF(A1:A10,A1:A10)>1)*1) which in this case would give you 6.
EDIT
For multiple columns, replace COUNTIF with COUNTIFS and extend with the columns you want to compare:
Formula in C1:
=SUMPRODUCT((COUNTIFS(A1:A10,A1:A10,B1:B10,B1:B10)>1)*(1/COUNTIFS(A1:A10,A1:A10,B1:B10,B1:B10)))
If you have Office 365 with the new Dynamic Array functions (currently available in the insider build), you can use the Unique() function and compare a count of the range with a count of the unique values of the range.
=COUNTA(UNIQUE(A1:A10))<>COUNTA(A1:A10)
Read more about the new Dynamic Arrays here.
Related
I want to count the number of cells that meet two conditions:
sheet ABC's A2:A100 should be equal to the value of sheet XYC cell A8
the cell value in range D2:M100 = 1
Originally, I tried to use this formula:
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$M$100,1)
But this gave me error #VALUE
I then decided to use the following formula to count each column separately and add them together.
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$D$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$E$2:$E$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$F$2:$F$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$G$2:$G$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$H$2:$H$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$I$2:$I$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$J$2:$J$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$K$2:$K$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$L$2:$L$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$M$2:$M$100,1)
I am wondering if there are any other ways that allows me to shorten my formula?
Thank you.
You can use a boolean structure inside SUMPRODUCT() or just SUM() if your version of Excel supports dynamic arrays (ms365):
=SUMPRODUCT((ABC!A2:A100=XYC!A8)*(ABC!D2:M100=1))
I was looking for a excel formula to do a task. Tried using Countif,Countifs. But with no luck. Any help is appreciated.
Task as below.
Type--------------Primary Color--------------Secondary Color
Car----------------Blue--------------------------Red
Bike--------------Black-------------------------White
Car---------------Blue--------------------------Blue
I need a formula which gives me a count of Cars having blue as their colour(Either Primary Or Secondary)
You can use following array formula (confirmed with Ctrl+Shift+Enter to calculate count of blue cars:
=SUM(N((B2:B4="Blue")+(C2:C4="Blue")>0)*(A2:A4="Car"))
or non array version:
=SUMPRODUCT(N((B2:B4="Blue")+(C2:C4="Blue")>0)*(A2:A4="Car"))
This part:
(B2:B4="Blue")+(C2:C4="Blue")>0
is an alternative way of expressing OR (not suitable for array formulas as it always returns a single value). N function converts boolean values to 0 and 1.
Edit: updated the formulas to include condition for A column.
What about adding a column with the following
=IF(OR(B1="Blue", C1="Blue"), 1, 0)
and copy that down.
On another sheet you can sum that new entire column with
=SUM(D:D)
Of course you will have a worksheet reference to the other sheet attached to the SUM formula.
If you don't want to do an array formula you can just do 2 countifs formulas (which are easier for people to read than array formulas)
=COUNTIFS(b8:b12,"Blue")+COUNTIFS(c8:c12,"Blue")
I have Twocolumns A, B ..I am trying to get the sum of A like below.
=SUMIFS(
sheet1!$A:$A,
sheet1!$B:$B, ("AB", "BC", "CD")
)
But this formula is not working.
Please suggest me.
Try to use following formula:
=SUMPRODUCT((sheet1!$B:$B={"AB","BC","CD"})*(sheet1!$A:$A))
or alternatively you can use an array formula:
=SUM(IF(sheet1!$B:$B={"AB","BC","CD"},sheet1!$A:$A,0))
enter formula in the formula bar and press CTRL+SHIFT+ENTER to evaluate it......
If I'm guessing your intention right, you should have:
=SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"AB")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"BC")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"CD")
Add two helper columns: in D:D you have the list of valid values. In C:C you have a formula like this (change ; to ,). In F1 you have your sum like this:
=SUMIFS($A:$A,$C:$C,FALSE)
Now you can add any number of valid criteria in column D:D.
You can use SUMIFS to return an array (one for each criterion) and then SUM to sum those, i.e.
=SUM(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,{"AB","BC","CD"}))
This way retains the speed and efficiency of SUMIFS without needing repetition
If you have your criteria values in a range of cells you can simply reference the range, but use SUMPRODUCT to avoid "array entry"
=SUMPRODUCT(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,Z2:Z4))
where Z2:Z4 contains the criteria
Note: in both of these SUMIFS does all the "heavy lifting" - SUM/SUMPRODUCT is used simply to sum the resulting array
I want to get the sum of values represented by 1,2,3,4
eg: =SUMIF(D5:D23,"1",G5:G23)+SUMIF(D5:D23,"2",G5:G23)+SUMIF(D5:D23,"3",G5:G23)+SUMIF(D5:D23,"4",G5:G23)
How can I do this operation? Please help me.
You want to use SUMIFS:
=SUMIFS(G5:G23,D5:D23,">0",D5:D23,"<5")
You want to sum all values from G5:G23 where the value from D5:D23 is greater than 0 and less than 5. So you require 2 criteria. >0 and <5.
Here is the function:
SUMIFS(sum_range,criteria_range1,criteria1,sum_range,[criteria_range2,criteria2],...)
Example:
Edit
Is think you want a vertical lookup - VLOOKUP()
Formulas:
G6: =VALUE(VLOOKUP(D6,$B$25:$E$30,2,FALSE))
H6: =IFERROR(IF(SEARCH("Valve",VLOOKUP(D6,$B$25:$E$30,3,FALSE))>0,$D$23,0),0)
I6: =E6*$D$22
J6: =SUM(G6:I6)
Now select G6:J6, grab the handle at the bottom right, and drag to fill rows G7:J7 to G20:J20.
Now sum up all the columns.
Here is the file completed: http://www.filedropper.com/wpmccardiocosts_1
You should check this out, it is very handy: http://www.mbaexcel.com/excel/tutorial-how-to-decide-which-excel-lookup-formula-to-use/
It may be simpler to use an array entered formula using SUM and IF:
=SUM(IF(D3:D23={1,2,3,4},G3:G23))
entered using [ctrl]+[shift]+[enter] (an array formula)
This will allow for use of many variables in place of 1,2,3,4 such as not continuous numbers, text ect.
I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work
=COUNTIFS(W2:W13,"=4", X2:X13, "=4")
You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer
Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?
I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?
Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.
I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs