how to count number between certain range of rows? - excel

i would like to count number for every 7 rows, data are in one column. i use this formula, but it is not working.
from B8 to B14329, for every 7 rows, count number if it is equal to 3. so i know how many 3 in every 7 rows.
=COUNTIFS(B8:B14329, OFFSET($B$7,(ROW()-12)*7,0,7,1),B8:B14329,=3)
Thanks a lot!
i want something like this:
data count
3
2
3
1
3
3
1 4
1
2
2
3
3
1
1 2
.....
....
...

Simple and easy:
=SUMPRODUCT((B8:B14329=3)*(MOD(ROW(B8:B14329),7)=1))
Just change the =1 to your needs. To start with row 1 =1, 2 =2 ... 6 =6, 7 =0. This way, to start count at row 8 it is =1
EDIT: having your exaple now, you want something completely different... lol.
=IF(MOD(ROW(),7)=0,COUNTIF(A8:A14,3),"")
Put this in row 14 and then drag down... change the =0 as you need it.

Here's what I would do
Add a new column with the row index (8 to 14239) in your case
Add Yet another column, with a formula to tell whether the column you just added is a multiple of 7. Put it's value like "TRUE" or "FALSE"
You can use the MOD function to check the remainder of the division.
= MOD ( Number , Divisor )
By now, you should have, aside from the columns you already have, something like:
8-----FALSE
9-----FALSE
10-----FALSE
11-----FALSE
12-----FALSE
13-----FALSE
14-----TRUE
15-----FALSE
Once you have that, just apply a filter on the "TRUE/FALSE" column, select the "TRUE" values and you will be able to count the number of "3"s on the actual value column, by also using a filter on it.
I hope it helps, and it's easier than a really messy formula.

Related

Find all values in Column A which are present in Column B

Consider the sheet below:
A
B
1
4
3
5
2
2
5
0
4
1
I want to find if there is a match for each row of column 1 with any row of column 2. So ideally this would give me:
A
B
C
1
4
Yes
3
5
No
2
2
Yes
5
0
Yes
4
1
Yes
As a first and simple step, I am using =MATCH(A2,B2:B6) to get the index of the match and then manually calling this across the rows to get something like this:
A
B
C
1
4
6
3
5
-
2
2
3
5
0
2
4
1
1
I am now having a problem:
I want to apply this for a row of 500 in A and 2000 in B. I was thinking of manually filling in the first few rows and then select and drag over the first 500 rows. This however does not work as for each subsequent cell, it just changes the formula to =MATCH(A(N +1),B2 + N:B6 + N) which gives me wrong values and at worst, just repeats the older pattern ahead.
Can anyone help me with how I can just use the MATCH function to find all the values in A that are present in B?
Let me continue where you arrived:
=MATCH(A2,B2:B6,0)
(You forgot the last zero)
This formula is correct, but it is also wrong.
???
Well, when you drag it down, you get:
=MATCH(A3,B3:B7,0)
This is not what you want: you want the search term (A2) to change into A3 but you want the search array (B2:B6) not to change. In order to get this done, you need to work with absolute references. This looks like this:
=MATCH(A2,B$2:B$6,0)
When you drag this down, this is what you get:
=MATCH(A3,B$2:B$6,0)
=> ok so far.
Problem now: you need to translate your current results (a number or #N/A) into "yes" or "no". This can be done in numerous ways, let me give you an example:
=IF(ISERROR(MATCH(A2,B$2:B$6,0)),"No","Yes")
One remark: there exists an IFERROR() function in Excel, but this does not have an "else"-clause, hence the choice for the IF(ISERROR( combination.
Within Sheets you may try this out:
=index(if(len(A2:A),if(ifna(xmatch(A2:A,B2:B)),"Yes","No"),))
If you want to separate those matching values then could use FILTER() function.
=FILTER(A1:A5,COUNTIFS(B1:B9,A1:A5))
And for YES, NO dynamically, try MAP() function.
=MAP(A1:A5,LAMBDA(x,ISNUMBER(XMATCH(x,B:B))))

Duplicating Data per number cycle

Im trying to duplicate data down a set of columns based on number cycle. Every time a number in sequence repeats, I'd like the number IM populating to increase by 1.
For example:
A
B
1
1
1
2
1
4
2
1
2
2
2
4
Every time column B repeats its cycle, In this case when it repeats back to 1, 2 ect. I'd like column A to increase by 1.
Initially I thought something like =IF(A3<>A2,B2+1,B2) would suffice, but that repeats.
Is there a different formula I can use to accomplish this?
Depending on your scenario, I'd do this.
These formulas need to originate in cell A2. If you're not working in the top left hand corner of your sheet, you'll need to adjust the formula accordingly.
Scenario 1 - All numbers in the sequence are unique.
=IF(INDIRECT(SUBSTITUTE(ADDRESS(1,B2),"1","") & "1") = B2, MAX($A$1:A1) + 1, MAX($A$1:A1))
Scenario 2 - All numbers in the sequence are NOT unique.
=IF(SUMIF($A$1:A1, MAX($A$1:A1), $A$1:A1) / 6 = MAX($A$1:A1), MAX($A$1:A1) + 1, MAX($A$1:A1))

how to reference a specific cell in a formula if other cells match a specific value

Thanks so much for looking at my question! I am trying to create a formula that subtracts a specific value from another formula. However, that specific value may change.
Example:
A B C D
1 1 100 =(2000 - ( if A = 1, i want to subtract the C value where B =1))
1 2 250
1 3 310
1 4 .
2 1
2 2 =((2000 - ( if A = 2, i want to subtract the C value where B =1))
2 3
2 4
3 1
3 2
3 3
3 4
(A,B,C,D are the columns)
Hopefully this makes sense! I am trying to subtract the C value that goes along with the B1 value for each different A.
I was thinking an index match of some sort but wasnt exactly sure how to do that when the A's change. Thanks so much in advance for help!
INDIRECT or INDEX functions can help you. See this answer.
Would something like a nested if function work for you here? For example:
=IF(A2=1,IF(B2=1,2000-C2,"Enter calculation if B2<>1"),"Enter calculation if A2"<>1)
If this works, then you can simply copy/paste the function down the rows in column D.

Average ifs with or in excel

So, I have this problem, I would like to find the average of a column by using the OR function to check criteria from adjusted columns, I tried putting OR into AverageIf function, fail, also tried the "Average(IF(OR(" again not the correct return. Thought it is a simple thing could be done easily but don't know why it doesn't work. So my table is something like this:
ID: Rate Check 1 Check 2 Check 3
1 5 1 1 1
2 3 1 1
3 2 1
4 4
5 5 1 1
6 3
7 4 1
I would like to find the average of the rate column by checking if there are any value in either Check 1; Check 2 or Check 3 columns, so in the above case i will get the average of all but row with the id 4 and 6. Is this possible without using a helper column?
You can use SUMPRODUCT()
=SUMPRODUCT(((C2:C8<>"")+(D2:D8<>"")+(E2:E8<>"")>0)*(B2:B8<>"")*B2:B8)/SUMPRODUCT(--((C2:C8<>"")+(D2:D8<>"")+(E2:E8<>"")>0)*(B2:B8<>""))
If your first ID starts in A2, use this formula (edited to handle empty values in the "Rate" column):
=AVERAGE(IF(MMULT(LEN(C2:E8)*LEN(B2:B8),ROW(INDIRECT("1:"&COLUMNS($C$1:$E$1)))),B2:B8))

Excel 2013 complex countif formula

I have a source sheet set up like this:
Days Open Month
10 1
4 1
6 1
2 1
4 2
2 2
-1 2
4 3
6 3
7 4
3 4
etc
I'm trying to set up a formula to count rows based on the following criteria:
cells in Days Open column <=5 and <>-1 where the month is either 2, 3, or 4 (the worksheet will eventually have month numbers up to 12, and I need to group results quarterly). The total must then be divided by the total of ALL rows in which 2, 3, or 4 appears in the Month column.
I can't seem to get the first part of the COUNTIFS to work with both criteria... this is what I have so far that I'm trying to make work:
=COUNTIFS('Cumulative Complaints'!K:K,"<=5",'Cumulative Complaints'!K:K,"<>-1")/(COUNTIF('Cumulative Complaints'!L:L,"2")+COUNTIF('Cumulative Complaints'!L:L,"3")+COUNTIF('Cumulative Complaints'!L:L,"4"))
I've been looking around here and other excel forums and think maybe SUMPRODUCT is the way to go? I haven't been able to get that to work though, given the criteria needed on the Days Open column (<=5 and <>-1).
Try this SUMPRODUCT() FORMULA:
=SUMPRODUCT(('Cumulative Complaints'!K:K<=5)*('Cumulative Complaints'!K:K<>-1)*('Cumulative Complaints'!L:L>=2)*('Cumulative Complaints'!L:L<=4))/SUMPRODUCT(('Cumulative Complaints'!L:L>=2)*('Cumulative Complaints'!L:L<=4))
When using the SUMPRODUCT the condition AND is replaced with the *. It requires all four conditions to be True to return a 1; 1*1*1*1 = 1 if any are false they return 0 so 1*1*0*1 = 0. So as it iterates through the rows it returns a 1 or a 0 to the be added to the sum.
Wrapping a COUNTIF or COUNTIFS function in a SUM function allows you to use an array of constants as OR citeria.
=SUM(COUNTIFS('Cumulative Complaints'!K:K, "<>"&-1,'Cumulative Complaints'!K:K, "<="&5,'Cumulative Complaints'!L:L, {2,3,4}))/SUM(COUNTIF('Cumulative Complaints'!L:L, {2,3,4}))
This is not an array formula and does not require CSE.
My answer would be to take a different approach.
Excel has a very powerful feature called Pivot Tables, and I think it might be a good fit for your problem and other similar problems you may face.
First, I would add a couple columns to your table, like so:
Days Open Month Quarter RecentlyOpened
10 1 1 FALSE
4 1 1 TRUE
6 1 1 FALSE
2 1 1 TRUE
4 2 1 TRUE
2 2 1 TRUE
-1 2 1 FALSE
4 3 1 TRUE
6 3 1 FALSE
7 4 2 FALSE
3 4 2 TRUE
The formula for Quarter is: =CEILING(B2/3,1)
The formula for RecentlyOpened is: =AND(A2<>-1,A2<=5)
Second, select the table, and do Insert > Pivot Table.
Third, drag from the fields to the boxes, like so:
Drag Quarter to the ROWS box
Drag RecentlyOpened to the FILTERS box
Drag Month to the VALUES box
Fourth, click Sum of Month, and select Value Field Settings to change Sum to Count.
Fifth, set the RecentlyOpened filter to TRUE.
The result is this:
Pivot Tables often provide a solution that is more flexible and easier to read and understand versus complex formulas.

Resources