Excel code to sum the last 7 cells in a row but if one of the values is 0 reset and start adding cell rows to the right as entered - excel

I'm using Excel Office 365. Col A = Total hours Col B Name Col C-Y head.Date/Day entered hours worked. I am trying to sum the latest seven days hours entered and totaled in column A. I have completed this step. The difficulty I'm having is that if the hours entered in columns C-Y is equal to zero I need to reset the Total Hours and start adding the hours on the next cell.
=SUM(OFFSET(B4,0,COUNTA(C$4:CC$4),1,-7))
sum the hours from the most recent entries.

You are not showing the full range so I am assuming that you are looking for the last 7 cells in the not blank area. Try this one:
=IF(SUM(OFFSET(B4,0,COUNTA(C$4:CC$4),1,-7))=0, 0,SUM(OFFSET(B4,0,COUNTA(C$4:CC$4),1,-7)))
Hope it helps

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.

Formula for if a cell is blank, It will consider the previous cell as the value for that cell and sum the cells together

I am trying to figure out how to sum a row of cells where if a cell in the row has a letter, for example a letter "X", to consider the cell to the left of it in the row as a value for that cell when summing up the row. For my table the reason behind this is I have a table that is for a construction project work week where each day I list the amount of employees work that day. On their off day I still need to consider them for when I sum the project up and pay for their hotel on the days they don't work. Also the employee count per day can change throughout the duration of the project. Example of this bellow:
A B C D E F G H
5 5 5 5 4 4 X 4
So for this A through G is considered Monday-Saturday. Monday-Thursday I have 5 employees, while on Friday-Sunday I will have 4 Employees even though the 4 employees didn't work on Sunday for their off day I still need to sum the week up to charge a daily hotel price since the 4 employees will come back the next monday, which is "H" above and continue to work.
So is there a formula where I if I am summing up the row and it finds an X then it will sum the previous cell two times? And I do not want to add employees to the Sunday column because I have another formula that sums the work days to charge their hourly pay rate.
Enter this array formula in next cell ( with ctrl shift enter )
=SUM(IF(COLUMN(A1:H1)<=COLUMNS(B1:H1),NOT(ISNUMBER(B1:H1)))*(IF(ISNUMBER(A1:H1),A1:H1,0)))+SUM(A1:H1)
Obviously it won't consider if first cell contains an X. Rest in any of the cell if X is there, it will add up the previous value twice
Moreover it'll work if cell contains any numeric character
If it's always about the Sunday containing an X or not then I guess this is what you mean:
=IF(G2="X",SUM(A2:F2)+F2,SUM(A2:G2))

Excel... Sum a row of values based on a character in the value

I have 31 columns representing each day of the month. I have 2 housekeepers cleaning rooms. The rows represent the villa numbers from 1 to 18.
Housekeeper #1's name starts with "A" and housekeeper #2's name starts with "L"
I need to total the number of cleaning hours for housekeeper #1 in column AG and housekeeper #2 in column AH. The hours spent cleaning is a digit on the right side of the name.
The cells go across a row from B5:AF5 and look like this
Ann4__Ann3__Ann7__Lisa2__Lisa4__Ann4__Lisa1
For the "Ann" hours totals in AG5 I have tried using SUMIFS with this formula
=SUMIFS(right(B5:AF5),left(B5:AF5),"A") but Excel returns an error.
I also tried SUMIF for the number of hours for Ann
=SUMIF(LEFT(B5:AF5),"A","(RIGHT(B5:AF5)*1)) Excel still says error.
The hours digit after each name is text, so I tried multiplying the result by 1 to convert to numeric.
For Ann:=SUM(IF(LEFT(A1:D1,3)="ANN",RIGHT(A1:D1,1)*1,"")). For Lisa:=SUM(IF(LEFT(A1:D1,4)="Lisa",RIGHT(A1:D1,1)*1,"")). Both are Array entered with Ctrl+Shift+Enter

sum assigned vlaues if sum for each value meets a specific criterion

in excel, I have two columns. one containing months of the year (in numbers) each month number occurring in different number of rows, and in the second column I have a duration of time for each row (in hours and minutes).
now I want to do the following job with an excel function in just one cell (the same job could be done using a table with 12 cells, each for one month but I want to pack it all in one cell):
1- for each month number, sum all cells in the second column (time) which have that month number in the adjacent cell (this could be done with a sumif )
2- if that sum is more than 4 hours then return one for that month else return zero (this step could be done with a formula like this: IF(R10>(--"4:00");1;"") )
3. in the end the numbers assigned to each month summed together.
thanks to everyone who helps
the picture below, shows the steps:
enter image description here
Try,
=SUM(--(SUMIFS(Table1[time],Table1[month],{1,2,3,4,5,6,7,8,9,10,11,12})>TIME(4,0,0)))

Resources