Formula to calculate difference in time for specific criteria - excel

I am attempting to calculate the downtime of our washers. I have an Excel sheet which displays all our cycle information for our washer machines.
Column B is the start time of the Machine.
Column E is the time difference between one cycle and another.
Column J displays either "None" or "General Washer Error".
What I am attempting is to calculate the time between the last successful Washer Cycle (Where J="None") and the next successful Wash Cycle, but only where there is a failure between them (Where J="General Washer error").
I know I can total the E Column, but this will give me an inaccurate total of downtime as it adds all successful Cycles also.
I have attached an image of the sheet for help.

I think this formula is what you want:
=SUMIFS(E:E,D:D,"<>none")
This assumes that System Error Text is actually in column D instead of column J. The image seems to show this, contrary to the description.
Edit 1
Ok. Based on your actual worksheet you sent me:
1.) The data in column E are entered into the worksheet as text. They are not numbers. So the SUMIFS() function that I used in my 1st formula will never work for text values. For example, my formula produces a total of zero (not an error) when I open your spreadsheet here with your text values.
2.) Since the formula did not error on my machne I suspect that you are using an older version of Excel that does not include the SUMIFS() function and that is why you get an error instead of a zero.
So, you need a different formula. Here is one that will work in older versions of Excel and it does not care that the values stored in column E are actually text instead of true numbers:
=SUMPRODUCT((D3:D2002<>"none")*(E3:E2002))

Related

Excel multiple running totals

I'm trying to make a simple formula for multiple running totals.
Basically, it's for recording transactions for different accounts, showing the running total of that particular account for each row. So, it's impossible to use SCAN+LAMBDA function. One way to do it is to have a set of helper arrays somewhere, but here I'm using another way, by using XLOOKUP.
=C2+XLOOKUP(D2,D$1:OFFSET(D2,-1,),E$1:OFFSET(E2,-1,),0,,-1)
Basically, it looks up the last account balance above the current row of the corresponding account and add the current transaction amounnt to it. It works by draggin down to all the transaction rows.
Since the number of transactions is over 10 thousand, I was trying to minimize the file size by using named function with LAMBDA.
Name: AddtoBalance
=LAMBDA(c,c+XLOOKUP(OFFSET(c,,1),Sheet1!E$1:OFFSET(c,-1,1),Sheet1!F$1:OFFSET(c,-1,2),0,,-1))
And changed cell E2 to
=AddtoBalance(C2)
and dragged it down to all transaction rows.
However, after saving and re-opening, the cells are having errors. I have to go to Name Manager, click Edit but without doing anything and Close it. Then the cells becomes fine again. It seems to me that when re-opening a workbook, the formulas are not calculated sequentially from top to bottom. Is that right? Is there any options to change it?
I think you are going to hate me when you see this…
Put this in E2:
=SUMIF( B$2:B2, B2, C$2:C2 )
Then copy it down. Mind the dollar signs, they are important. You could place this in a named Lambda but the character count reduction is probably immaterial.
After rebooting and restarting excel, actually I could not reproduce the error. It works fine with the Lambda function now.
Whole different approach, but how about:
=LET(f,ISNUMBER(C:C),
c,FILTER(C:C,f),
d,FILTER(D:D,f),
s,SEQUENCE(COUNTA(d)),
MMULT(
(d=TRANSPOSE(d))*(s>=TRANSPOSE(s)),
c))
It first creates an array of TRUE's and FALSE's on column C:C if it contains a number. This is used to filter the values to be used from column C and D.
A sequence of the count of filtered values in column C is used to simulate it's row number in that filtered range.
Now MMULT checks row by row how many values of column D equal it's current value where the sequence number for that "row" is smaller or equal than the current.

Is there a formula that will count the number of terms in a mathematical equation in Google Sheets or Excel?

I use Google Sheets to keep track of how I spend my time at work. One of those tasks is email. I want to know how many times I check my email and how much time it takes out of my day.
Currently if I checked it four times during the day, I enter Email|4 in Column D, and then, e.g. =3+2+5+1 in Column E.
If I want to analyze the cumulative data, the pipe character lets me use a formula to get that "4" out of the cell in D, but I would rather not have to enter it at all.
Is there a formula that will look at the cell in Column E and return the number of terms being added together? So, if E28 is =4+1+2+3+1 it would return "5"?
I will be starting a new job soon and building a new spreadsheet, so I can switch to Excel if that would provide functionality that GSheets doesn't.
try:
=COLUMNS(SPLIT(A1; "+"))
or if your cell is 11:
=COLUMNS(SPLIT(FORMULATEXT(A5), "+"))

how to group same values into Excel array

I have a duplicate value in column A with different value in column B and column C.
For example:
There are 3 column which is A, B and C.
- A has duplicate value which is serial number
- B is whether it fail the test or not
- C is the time for testing.
Is it possible with Excel to find time difference between time for first fail and pass?
I want to delete the data that have less than 12 hour so that I know the things don't need rework, just retest. I want to know the exact number of modules that need rework.
=IF(AND(B7 = "pass",B6 = "fail", A7 = A6),TEXT(C7-C6, "h:mm"), "")
To get the difference between last fail and pass use this formula in cell D7. If the cell in column B is pass and previous cell was a fail, it will work out the time difference between the previous cell that was a fail. It will also check that the cell in column A matches previous cell in column A. Can also try using Index / Match or Vlookup to get the first fail by formula. As Tim Williams said a pivot table will also help. I don't use them much, so I'm not sure how to get the time difference with a pivot table, but it'll make viewing the data easier.
You could also try adapting this formula, by nesting conditions to get the previous cell that is the first fail. Work out the maximum number of cells between a pass and a first fail, and nest it that many times. If there are cases where the fail time is later than the pass it will throw an error. If you have multiple consecutive pass cells, for the same element you'd need to add more conditions to account for that, but if there's only 1 pass per element this should work.
=IF(AND(B7="pass",B5="fail",A7=A5),TEXT(C7-C5,"h:mm"),IF(AND(B7="pass",B6="fail",A7=A6),TEXT(C7-C6,"h:mm"),""))

excel Sum every other column up to certain month

I have a Simple spreadsheet with 2 rows:
ActualJAN | BudgetJAN | ActualFEB | BudgetFEB | ActualMAR | BudgetMAR ....
100 200 300 400 500 600 ....
I'd like to sum ONLY the Budget columns up to the current month (Month(Today()).
Same for the Actual columns.
So if we're currently in February,
Budget to date would be: 600=200+400
Actual to date would be: 400=100+300
I just can't seem to get there, at least simply and elegantly.
This is a non array formula that performs array like operations. As such large range references should be avoided or you will experience a slow down or potential crash of your system. For a small defined range works great so long as the formula is not repeated too many times either.
Additionally TODAY() is a volitile function which means the formula will recalculate whenever anything in the spreadsheet changes, not just when something related to the formula changes.
This formula is generalized a bit so your data can be located anywhere on your sheet and does not require rearrangement of your data.
To get your actual sum use the following:
=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="A"))
To get your Budget sum use the following:
=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="B"))
Change C4:H4 to suit your number range. ChangeC3:H3 to suit your column title range. Change C4 to be the first cell of your number range.
Caveat: Assumes maximum 12 months starting at January
Proof of concept:
I would recommend structuring your data differently. It would be an easier task if you arrayed everything vertically and divided your data into three columns. The first would be Category, which would be populated with either "Budget" or "Actual." The next column would be Month. After that, of course, you have the Value column. Then, use a basic SUMIF, like "=SUMIF(A1:A6,"Budget",C1:C6)." A1:A6 is the range Excel will scan for the desired variable. In this case, that variable is "Budget." Then, C1:C6 is the value that corresponds to a "Budget" month. That formula will give you the answer you want as long as you expand the SUMIF formula to include the full range of values, e.g., "SUMIF(A1:A317,"Budget",C1:C317)."
So I think I understand what you're trying to do, I cannot make the entire formula without the rest of the spreadsheet but this is working currently:
For the Actual:
=IF(MONTH(TODAY())=1,A2,IF(MONTH(TODAY())=2,A2+C2,IF(MONTH(TODAY())=3,A2+C2+E2,"")))
For the Budget:
=IF(MONTH(TODAY())=1,B2,IF(MONTH(TODAY())=2,B2+D2,IF(MONTH(TODAY())=3,B2+D2+F2,"")))
Here is the spreadsheet I created to test:
If you give me the rest of the data I can complete the formula, basically all you would need to do is add more months to the formula and change the amounts it adds.
I am sure there is probably a more efficient way to accomplish this but this way works.
I suggest a hidden row to control your dates. Say, January is in column C, enter [C1] =1, [D1] =C1, [E1] =C1+1, [F1] =E1. Select E1:F1 and copy to the right until December. Hide row 1.
In row 2 use these two formulas.
[C2] ="Actual" & UPPER(TEXT("1/" & C$1,"mmm"))
[D2] ="Budget" & UPPER(TEXT("1/" & D$1,"mmm"))
Select C2:D2 and copy to the right until December. This exercise isn't required because the resulting display is exactly what you already have. But producing this result with the help of formulas ensures freedom from error, and it is faster. As an added bonus you get a visual check of what's in the hidden row.
Now you can use this formula to extract totals from row 3 where you have your values.
=SUMIFS($C3:$Z3,$C$2:$Z$2,"Budget*",$C$1:$Z$1,"<="&MONTH(TODAY()))
Change "Budget" to "Actual" and the same formula will extract the actual amounts.

excel count/sum stop count/sum match?

I have tried to see if this question has been asked before, but I can't seem to find an answer.
I have a column of cells (>3000 rows), with either a value of 1 or 0 (call this column A). The value will depend on the value in column B (which will contain either a value or nothing). The values in column B are a SUMIFS function based, summing from column C, and based on months in column D.
The values in B are paid out on the first business day of the next month. So, the SUMIFS function will calculate the dates that match the last month. This works well in theory, however, not every first business day is the first day of the month. This leads the SUMIFS function to not include everything in the correct month, and allows for some discrepancy, which, when you are dealing with people's money is not great. Further, this discrepancy is compounded across multiple periods (in some cases, there are over 100 periods, and a discrepancy of $1 in period 1 amounts to nearly $1000 in period 100)
What I am wondering is:
Is there any way that I can tell the SUMIFS function (column B) to stop when the value in column A is 0? This would tell the SUM function start the summing from the current value in column B and continue the function to the cell below the preceding value in column B.
I've seen suggestions that the MATCH function may work, but I can't see how to do this with either COUNT or SUM.
For security reasons, this solution needs to be entered into the cell, and can't be VBA. Also, it can't be too large, as it will need to be replicated across 200 worksheets in the workbook (not my file originally, and I would have done it differently, but that is another story). There is no problem entering another column or two if that is required.
Any help is gratefully appreciated.
EDIT:
Unfortunately, I can't post an image of the screenshot. I've included a similar screenshot (columns are not the same layout, but hopefully it gives the idea) here:
Rates calculations
The SUMIF formula is (for B2)
=SUMIFS(C2:C35,D2:D35,D2-1,A2:A35,1)
This works fine if I want all the values in the month, irrelevant of when the payment was made.
However, what I need the formula to do is:
SUM (C2:C35,D2:D35,D2-1, but stop when the first 0 is encountered in A2:A35)
Thanks
The INDEX function can provide a valid cell reference to stop using a MATCH function to find an exact match on 0.
This formula is a bit of a guess as there was no sample data to reference but I believe I have understood your parameters.
=SUMIFS(C2:index(C2:C35, match(0, A2:A35, 0)), D2:index(D2:D35, match(0, A2:A35, 0)), D2-1)
This seems to be something that will stand-alone and not be filled down so I have left the cell addresses relative as per your sample(s).

Resources