Excel - Call a function within a function - excel-formula

Scenerio - I have an Excel formula that counts the number of "YES" entries in a column then divides that count by another count of "YES" entries in a different column
=COUNTIF('All Project Tasks'!AC203:AC236,"YES")/COUNTIF('All Project Tasks'!AB203:AB236,"YES")
This works.
However, I now need to add a criteria that checks to see if the date in a date column is <= to today and if so, it should result with "Not Started" instead of the division result.
So far I have this:
=IF(D12<=TODAY(),COUNTIF('All Project Tasks'!AC2:AC18,"YES")/COUNTIF('All Project Tasks'!AB2:AB18,"YES"),"Not Started")
The "Not Started" part works in this formula but the division part is failing. I receive 0 instead of the decimal number that I get by using the first formula above.
I'm thinking I'm just missing one piece but cannot find what it is.

You could try storing the results from the formulas in different cells, then diving the cells by eachother

Related

Using COUNTIF but not including blanks with other formula

Firstly, apologies if this is covered somewhere deep within the site, I have looked through a lot of other posts and none of the solutions have worked for me.
I'm creating a workbook for a local league I'm involved in and this is the only sticking point I'm coming up against.
In cell J55, I have the formula:
=IF(C11=H55, COUNTIF(D11, "="&E11),0)+IF(C19=H55, COUNTIF(D19, "="&E19),0)
(I've simplified this to only look at rows 11 & 19 for the purposes of this question)
So what I'm essentially saying is if the team name is equal to the corresponding name in the table, count if the scores for both teams are equal. Basically I'm trying to get the number of games that end in a draw.
So at it's core, my formula is looking for whether 2 cells are equal. This is fine, other than it is counting even if the score cells are blank.
So if you refer to the below image, in J55, I'm getting the returned value of "2". However for the values I've populated in the results (just the scores in the first game) it should be returning a value of "1".
If anybody can help in any way it would be a great help.
To count the number of Draws this formula which performs array like calculations will count the number of occurences where where the team name in H55 is equal to the team name in column D or F and when the scores in column D and E are equal:
=SUMPRODUCT((($C$11:$C$21=H55)+($F$11:$F$21=H55))*($D$11:$D$21=$E$11:$E$21)*($D$11:$D$21<>"")*($E$11:$E$21<>""))
Copy down as required.
COUNTIFS options
Based on your formula above, adding the checking for not blank cells using COUNTIFS.
=IF(C11=H55, COUNTIFS(D11, "="&E11,D11,"<>"&""),0)+IF(C19=H55, COUNTIFS(D19, "="&E19,D19,"<>"&""),0)
COUNTIFS is probably the slightly better option as it does not use array calculations. However for a small data set it wont make a noticeable difference in calculation time for most users.

Excel - Minimum and If statement - date error

I am trying to write a formula that checks the status and name to be ongoing and joe blogs (in this example), and once finding a match, will identify the oldest date of a ticket raised.
My formula currently includes:
=MIN(IF('Sheet2'!AA:AA="ONGOING",IF('Sheet2'!Q:Q="Joe Bloggs",'Sheet2'!B18:B49)))
I also tried:
=IF((AND(sheet2!$AA:$AA="ongoing", 'Sheet2'!$Q:$Q="Joe Bloggs")), MIN('Sheet2'!B18:B49),"No")
In Column B contains dates. Q contains names, AA contains the status.
At the moment when this runs I get the result '00/01/1990'.
I have done some checks to find the error, and appears to be around the targets name, as when the second formula is tried, the output is "no". The name is definitely in the Q column, and I have completed other formulas including countifs which have worked perfectly fine.
I have done a lot of searching to find nested ifs and min statements to have no joy , would be grateful of any advice / tips. It may be a simple error to some.
Try entering this as an array formula:
=MIN(IF(sheet2!AA:AA="ongoing",IF(sheet2!q:q="Joe Bloggs",sheet2!B:B)))
FYI I found the solution here.
You will have to apply a date format to the result.
Your first formula works well on my data (as below). If I close the formula with ENTER only, I get the result '37128' and if I close the formula with CTRL+SHIFT+ENTER I get the expected result, '25/08/2001'.
Edit: As #FocusWiz said in the comments, the only major difference (other than different column names) between my formula and yours is the the last range in your formula (B18:B49) is a different sized range to the other two, which are referring to full columns.
*This could be solved either by using the same row range for all three column references (AA18:AA49, Q18:Q49, B18:B49) or referencing the full column range for all three ranges (AA:AA,Q:Q,B:B).
This is your formula I'm talking about:
=MIN(IF('Sheet2'!AA:AA="ONGOING",IF('Sheet2'!Q:Q="Joe Bloggs",'Sheet2'!B18:B49)))
And this is the formula in my workbook F7:
=MIN(IF(B:B="ONGOING",IF(A:A="Joe Bloggs",C:C)))
As you can see in the formula editor, squiggly brackets '{}' show around the formula when it has been closed as an array formula.
If that doesn't work for you, please post some sample data with datatypes so we can help figure out what is causing the lookup value to miss the data.
While I like the technique offered by Patrick (I have frequently forgotten an "else" portion of a formula and gotten "false" as a value in a cell but never thought of a use for that...thank you!), I think this question highlights an issue we all can have with array formulas. As girlvsdata indicates, your original formula:
=MIN(IF(Sheet2!AA:AA="ONGOING",IF(Sheet2!Q:Q="Joe Bloggs",Sheet2!B:B)))
(modified above to be more generic for column B) will also work when entered as an array formula.
What likely happened is that somehow the formula got edited and was not re-entered as an array formula.
While I do not dislike array formulas, I do try to avoid them because I have fat fingers and will frequently mess them up by accidentally hitting the wrong key as I am modifying other cells.
Here is an alternative without using an array formula:
=INDEX(LARGE((Sheet2!Q:Q&Sheet2!AA:AA="Joe bloggs"&"ongoing")*(Sheet2!B:B),COUNTIFS(Sheet2!Q:Q,"Joe Bloggs",Sheet2!AA:AA,"ongoing")),1)
What it does is basically create a candidate date value for every row that has "joe bloggs" and "ongoing" which is equal to the date in column B for all such rows. All other rows get a zero candidate date value. The LARGE function takes the smallest nonzero date by counting the n valid candidates with the COUNTIFS function and taking the nth largest such candidate.

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"),""))

Return value with multiple criteria

i'm trying to get the following result with a formula. In the picture below you can find 5 possible outcomes from the data.
Colomn A: check of a test is done
Colomn B: Testname or testnumber
Colomn C: Result of the test taken
Every test will get a unique number, but will be duplicated every time a test has been done. Whatever the outcome.
So every test number can only have one "YES" in column A, all the other attempts should be "NO" and if the test results eventually becomes "SUCCESS" it should turn "YES" in column A for this line and all the other attempts should turn to "NO" for that particular test number.
The result "SUCCESS" overrules everything and "ERROR" overrules "NOT TESTED".
I've managed to put YES for every unique results, but I'm stuck at turning this YES to NO if the results is eventually SUCCESS.
If I understand your requirement correctly, it sounds as though you may be able to achieve what you need using the COUNTIFS formula, providing you can get a unique list of test names. There is a formula method to get a unique list, but using it on such a large dataset will likely drain your Excel's resource, so it may be easier to just use an advanced filter.
You can use the formula to count per test name the volume of successes, errors and non tests.
I've taken your data from your post as though that were the source data, to give the following output:
Enter the following formula in F2, and you can then drag down and right to fill F-H. You'll obviously need to extend your ranges to suit your actual data source.
=COUNTIFS($A$2:$A$17,$E2,$B$2:$B$17,F$1)
In I2, use a simple IF formula to evaluate the counts and return the overall status based on your "Success > Error > Not Tested" heirarchy.
=IF(F2>0,"Success",IF(G2>0,"Error","Not Tested"))
This should keep it fairly simple to read and alter when required, but if you didn't want the individual status count columns, then you may change the IF formula to include the COUNTIF formulas within, and manually reference the status descriptors, like so:
=if(COUNTIFS($A$2:$A$17,$E2,$B$2:$B$17,"Success")>0,"Success",if(COUNTIFS($A$2:$A$17,$E2,$B$2:$B$17,"Error")>0,"Error","Not Tested"))

Formula to calculate difference in time for specific criteria

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))

Resources