Sum first n non-blank values in a column in date order and stop at row X - excel

There are three columns in a document:
column A contains Names of people,
column B contains Dates and
column C contains Numbers/Values. Column C may contain BLANK rows.
There is a row for each day for each person for e.g. the past two years so over 600 rows per person. I need to do the following:
Make sure that values are taken in date order
Per person
Pick up the first 52 non blank values from column B and sum them
But stop when you reach row 120 (even if this means that you don't get to sum 52 values)
Divide by the count of the number of non-blank values that you found before reaching row 120
For example:
We look at Joe and he has 52 non-blank values in column C before day 120 so we sum these 52 values and divide the sum by 52.
We look at Jane who has 30 non-blank values in column C before day 120 so we sum these 30 values and divide this sum by 30.
Any help hugely appreciated. I've been mind boggling with this for hours and can't figure it out...
Many thanks in advance !
N.

I'm not sure that your excel version supports SUMIFS() AND COUNTIFS(), if yes here is a solution with two "helper"-columns

Related

Excel - counting how many consecutive 0s in a row

I have multiple ‘people’ in rows in excel, with 10+ columns of system usage data. I want the final column to show how many consecutive months have 0 usage. For example, person a might have had 0 usage in March and April, used in June, then 0 usage in July - December, I would need the end column to show 6.
If your data is from B2 to M2 you could use the following formula:
=MAX(FREQUENCY(IF(B2:M2=0,COLUMN(B2:M2)),IF(B2:M2<>0,COLUMN(B2:M2))))
This will show the max number of consecutive 0's in that row 2 from column B to M.
Older versions of Excel require this array formula entered with ctrl+shift+enter
If you want the formula to show the quantity of consecutive zeroes of the last occurance in the row then you could use:
=LOOKUP(2,1/(FREQUENCY(IF($B2:$M2=0,COLUMN($B2:$M2)),IF($B2:$M2<>0,COLUMN($B2:$M2)))>0),FREQUENCY(IF($B2:$M2=0,COLUMN($B2:$M2)),IF($B2:$M2<>0,COLUMN($B2:$M2))))
I've made something for you, based on the numbers of the months in the year: 1-12 (in column "item").
In the "Value" column, there are the values zero or else.
The "Length" column contains the number of subsequent zeroes, based on following formulas:
First entry : =IF(B2=0,1,0)
Following entries: =IF(B3=0,C2+1,0)
Screenshot:
Have fun!
This might help if 2 is threshold for consecutive in F3:AI3
=SUM((FREQUENCY(IF(F3:AI3>=0,COLUMN(F3:AI3)),IF(F3:AI3<0,COLUMN(F3:AI3)))>=2)*1)
suppose I want count of values more than 10 in groups of 5 and more then
=SUM((FREQUENCY(IF(F3:AI3>=10,COLUMN(F3:AI3)),IF(F3:AI3<10,COLUMN(F3:AI3)))>=5)*1)
hope this helps

Only show the sum of a column if there are at least 3 records in another column

I have 3 Columns of data. Column E = Duration. The user will enter a number of days (Duration) for 20 employees. Column F = Pay. List of wage for each employee. Column R = Pay Total. This is a calculated field based on the number of days (Duration) and the employees pay (Pay).
To keep my employees from finding out their coworkers pay I only want to see a sum for Column C if there are at least 3 records in Column A.
I found this Sum only if 3
From that answer I tried to use =IF(COUNTIF(E2:E15,">2"),SUM(R2:R15))
What this does is only returns records with a duration of greater than 2 days. I don't care about the number of days. I want the indicator to be that there are 3 cells populated in this column.
I think the only issue with the formula is the CountIF part. I need to know what I should use to count cells not days.
Screenshot of My Sheet
In the image above you can see that it's returning a sum bc both records are greater than 2. Like I said before I don't care what number is in the cell I just want to see the sum if there are more than 2 cells populated in that column.
Thanks for any help
As per my understanding of the question, I came up with this solution. Give it a try.
=IF(COUNT($E$2:$E$15)>2,SUM($R$2:$R$15), 0)
This formula would give what you want
=IF(COUNTA(E2:E15)>2,SUM(R2:R15),"")
This would show sum only if count of non empty cells is greater than 2 in Range "E2:E15" else it would show empty.

How to get maximum number and name from 2 columns? (Excel)

I have this (example):
Luffy 320
Coby 350
Zoro 180
Now I want to show the max from this info, with number and text (in seperate cells) like this:
col 1 col 2 col 3
1st 350 Coby
2nd 320 Luffy
3rd 180 Zoro
The 2nd Column no problem with the MAX() formula.
For the 3rd column to get the text I've tried the MAX(...) and INDEX(...) formulas but nothings working ...
Can anyone help me?
You first need to get which value is the largest, second largest and so on.
You can use the function LARGE(range, n) for this.
So in your col 2 use this formula:
=LARGE(B:B,1)
=LARGE(B:B,2)
=LARGE(B:B,3)
Assuming B is the column with the values.
Then we need to match this value and get the name
=INDEX(A:A,MATCH("the above calculated cell",B:B,0))
With the above calculated cell I mean the LARGE function cell. And assuming column A is the column with the names.
This should give you a dynamic table that will update when values or names change.
I'm not sure how you manage to get that column 2 using MAX formula since it only outputs the largest number of the inputs and thus can't output 2nd and 3rd position.

How would I delete a row of data if none of the cells are empty?

I have a spreadsheet with sales data for a given month for a number of different stores. There are approximately 450 rows (stores) to go through. The days of the month are in row 1, starting in column B, with the store numbers in column A, starting in row 2. What I need to find are the rows that are missing data for different days. I can use conditional formatting to highlight the cells that are empty, but that is still a lot to look at. What I am trying to do is reduce the amount of cells to look at by deleting any rows that are not missing data. So if a row is not missing any days of data, then I don't need to look at it, and can delete it. But if it is missing data, then keep the row.
I'm stuck on figuring out the actual code, but I have come up with pseudo code for what I want:
foreach row in range ($B$2:$AB$450)
foreach cell in row
if cell < 1
delete row
end foreach
end foreach
Here is an example of the spreadsheet:
A B C D
1 12/1/2019 12/2/2019 12/3/2019
2 Site 1 1000 2000
3 Site 2 5000 5000 3000
4 Site 3 6000 4000 3000
In this example, rows 4 and 4 would be deleted because they are not missing any data.
Thanks
**assuming that you have 4 columns and they start in column B:
with an array formula you can see the length of characters in each row.
=MIN(LEN(B2:E2))
for example, you can use the above formula in row 2 (remember: ctrl+shift+enter to use it)
So, if you apply that formula per row, you should be able to know if you have missing value per row (all of them that have length 0 per row); then, use that column to filter. E.g. Filter anything that is not 0.

Find row when Cumulative sum reaches certain value with condition

I have a table with 3 columns Date, Item and Number. Each row indicates how many items of each Item was received on that date. I am trying to find the date on which cumulative sum reaches 100 or more in that month. Each month will have a target for each item which will be saved in another sheet but for simplicity we can assume that its a fixed number of 100.
Example Data:
Date Item Number
1/2/2018 A 10
2/2/2018 B 10
2/2/2018 A 15
5/2/2018 C 25
6/2/2018 A 50
7/2/2018 B 10
7/2/2018 C 10
8/2/2018 A 25
9/2/2018 A 20
I am looking for the formula which should act on the data similar to above and give the result as 8/2/2018 which is the date on which the cumulative sum for Item A reached 100.
Each month will have different target number, and will have different number of entries.
I have tried using SUMIF and adding a additional column etc but this data is just part of a big data and each item limit is saved in a different sheet etc which is not easy to merge. Thanks in advance for help.
In Excel only, you can use Offset to develop an array of items and numbers containing 1,2,3...9 rows and then SUMIF to add each of them up. Then use Match to find the first one =100 and Index to find the matching date (in F2):
=INDEX(A2:A10,MATCH(100,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1))),0))
Must be entered as an array formula using CtrlShiftEnter.
EDIT
To find the first sum which is >=100 (in G2):
=INDEX(A2:A10,MATCH(TRUE,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)))>=100,0))
Sum which reaches exactly 100
Sum which does not reach exactly 100 (the number in row 9 has been changed to 24):

Resources