Nested Excel Formula Modification Question - excel

I am trying to figure out whats wrong with a nested formula I created:
In the image you can see the three sections the formula is broken up into:
is grouping cells into buckets
is referencing a separate tab (city density scores) and selecting only if the value is less than or equal the value in that tab
is performing a lookup also referencing a separate tab, and pulling in that value as long as that condition is met.
There is a unique key linking all three tabs. If all three conditions/sections of the formula are met, the idea is to return the value "Select" and if not, "Don't Select."
When I ran this formula in excel I'm getting "Don't Select" for cells that meet all #1,#2,#3 criteria, trying to figure out what I am doing wrong.
This is the formula I created. I feel its a small change that I need to make:
=IF(AND(OR(AM6="1 to 3 Bucket",AM6="4 to 7 Bucket"),$BK6<='City Density Scores'!$H$6), IF((VLOOKUP(BI,'Rank Competition Vetting'!$A$7:$F$182,5,0))<33%,"Select","Don't Select"))

Your formula logic is a little off. The correct form is (replace BI6 with whatever the correct cell is)
=IF(AND(OR(AM6="1 to 3 Bucket", AM6="4 to 7 Bucket"), $BK6<='City Density Scores'!$H$6, VLOOKUP(BI6, 'Rank Competition Vetting'!$A$7:$F$182,5,0) < 33%), "Select", "Don't Select")
Lets break it down: you have 3 criteria, all of which must be true to return Select
You have
IF(AND(OR(#1a,#1b),#2), IF((#3,"Select","Don't Select"))
This will work if #1 and #2 are TRUE, and fail otherwise (returns FALSE) because you havn't specified a False clause for the outer IF.
You really want all 3 clauses in the AND term
IF(AND(OR(#1a,#1b),#2,#3),"Select","Don't Select")
Now, you say you still get a false negative for a case where you believe all 3 criteria are met. To me, this points to a data issue - perhaps some numbers formatted as text? In any case, using the Evaluate Formula tool will help. You say you are having trouble using it: the process is to
select a cell containing the formula, then activate the tool
press Evaluate button repeatedly
at each click the underlined part of the formula is evaluated.
read the Evaluation to see if it lines up with your expectation
Here's an example (of my formula) evaluated up to the point where the VLOOKUP is about to be processed

Related

Excel formula to search three ranges to determine value

Essentially what I'm trying to do is create a formula that will search three different ranges to determine the value of a cell using true/false statements.
I6 needs to return a value of "Complete", "Partially complete", or "Not complete" and it will be searching three ranges J7:J10 (COMPLETE), J11:J14 (PARTIALLY COMPLETE), J15:J19 (NOT COMPLETE).
Each range will have questions I7, I8, I9 and so on where the options are YES or to keep the cell blank.
What I'm trying to achieve is that IF J7:10 are all true THENI6 will display COMPLETE however IF any of J11:J14 are true THEN I6 will display PARTIALLY COMPLETE and IF any of J15:19 (can be just one cell) is true THEN I6 will display NOT COMPLETE
I've tried using COUNTIF, IF, VLOOKUP, ARRAY but I keep getting the dreaded #NAME
Any ideas?
My understanding is the question in Columns I will be answered in Column J with either a "Yes" or leaving the cell blank. I highly recommend using Data Validation to limit unintended responses. Assuming my understanding is correct, you can solve this with nested IF statements and COUNTIF/COUNTBLANK statements. Excel will evaluate nested IFs from left to right, so you need to order these in importance of priority (e.g. what if someone has a "Yes" in both the Not Complete and Partially Complete section?). My suggestion would be:
=IF(COUNTIF(J15:J19,"Yes")>0,"NOT COMPLETE",IF(COUNTIF(J11:J14,"Yes")>0,"PARTIALLY COMPLETE",IF(COUNTBLANK(J7:J10)=0,"COMPLETE","THERE IS A DATA PROBLEM")))
This assumes that one "Yes" in the Not Complete section overrides anything else, and that the entire "Complete" section must be true to get a Completed result. Note that you'll get the Data Problem error if you have all blanks everywhere.

Excel Sum if, critera range1 on a single cell

Title says it all pretty much, So in the image the sum looks for the first entry as it has "mr human" in the cell next to it but when i try to designate my critera range for a single cell i get #value returned, I can solve this by entering "mr human" into all the adjacent cells however to sheet I am pulling the data from has is formatted like It is shown so it would be ideal If i didnt have to make a copy then do that as this can be for several hundred "mr & Ms/miss"
Thanks for any help in advance!
First of all, I would say that you should indeed consider using a different model data for this, as suggested by #ScottCraner.
Second, this solution may work, but if you have a lot of sets (when i mean sets, i mean Mr Human, Miss Human, Kid Human, Grandp Human, and many more) it can be kind of annoying.
Now, first thing you must do is creating named ranges of each set of data. So the values related to Mr Human will be namedMR_HUMAN and values of Miss Human will be named MISS_HUMAN. It's easy to do.
Remember:
Names can't have blanks, spaces, or any weird char. Just use underscore.
Each name must be unique
Each name must contain 2 columns: first one is Code and Second one Cost.
A video example (type the name and press ENTER
Now the formula for column C:
=IFERROR(VLOOKUP(B3;CHOOSE(MATCH($A$3;{"Mr Human";"Miss Human"};0);MR_HUMAN;MISS_HUMAN);2;FALSE);"Not found")
You can see below that if I change cell A3 to Miss Human, values change properly:
This is how the formula works:
MATCH($A$3;{"Mr Human";"Miss Human"};0) This will search the text in A3 into the array of sets and will return a number according to position. In this case, Mr Human=1 and Miss Human=2
CHOOSE(*number from step 1*;MR_HUMAN;MISS_HUMAN) We use the number obtained in step 1 to combine with function CHOOSE, which allows to select a result based on a list. So we can use this function to relate number 1 to name MR_HUMAN and number 2 to MISS_HUMAN and it will return our target range with right values.
VLOOKUP(B3;*name from step 2*;2;FALSE) We combine the range from previous step and use it as matrix of a normal VLOOKUP, that will search the CODE in first column, and will return the value from second one (COST)
We trap all above inside an IFERROR, just to avoid VLOOKUP returning an error (error in VLOOKUP means that CODE is not found in that range).
The big issue here is that if you got a lot of datasets for more values, besides Mr Human and Miss Human, you need to adjust the MATCH and CHOOSE part, and can be annoying.
Anyways, hope this helps a little bit.
VLOOKUP
function
IFERROR
function
MATCH
function
CHOOSE
function
Also, consider using a different data model and the resume data using Pivot Tables.

How to Avoid Running a Formula From a Common Spreadsheet Under Certain Conditions

I am trying to run multiple scenarios in a financial model that all originate from one common set of formulas in a singular sheet. Simultaneously, I would like the results for all non-active scenarios (i.e. if the governing condition is not met) to remain displayed in their respective location instead of a "0".
My goal is to (i) avoid using the "COPY-PASTE" function for each scenario that doesn't meet the active criteria and (ii) leave all the formulas (which draw from the same spreadsheet) in their respective tables (Which summarize each scenario). While a traditional "IF" statement could work, I get hung up on what to put in the "FALSE" category seeing as I do not want to return "0". In the end, I have copy-pasted the results table three different times, and hope to display all results simultaneously without having to copy-paste the numbers.
Thanks.
If you want to use an IF statement but was to return "blank" value instead of false, you can use a Null String ("").
For example:
=IF(A1=B1,"They Match!","")
This will return They Match! if cells A1 and B1 match, otherwise the cell will remain blank.
This is more information about how to use the IF statement in Excel.

Pull data in columns according to a certain cell value

https://www.dropbox.com/s/zag18z5f13fugn3/Coverlog%20Rota.xlsm?dl=0
Hi
Just need a bit of assistance. Tried a few ways of doing this but can't seem to get it to work.
Below is the Forumlae I used:
Fair enough. Below is my Formulae that I've used.
=INDEX('Cover LOG'!$E$1:$AR$89,MATCH(A3,'Cover LOG'!$C:$C,0),MATCH($B$1,'Cover LOG'!$E$1:$AR$1,0)*2)
It works with the first date, but when it gets to the second date the last four columns give back #REF!.
When it goes to the third date the last six columns this time bring back #XREF!.
I've uploaded the file on the link as this was the only way I could explain it fully.
Essentially when the date changes at the top on the FC Dash I want the relevant columns from Cover LOG to pull through.
Can anyone help?
Jay
The issue is probably that one of the Match functions don't match and therefore the Index function fails. Or that the column/row exceeds the given range in the Index function.
So you need to evaluate your formula step-by-step:
Select the cell that you want to evaluate. Only one cell can be evaluated at a time.
On the Formulas tab, in the Formula Auditing group, click Evaluate Formula.
Click Evaluate to examine the value of the underlined reference. The result of the evaluation is shown in italics.
If the underlined part of the formula is a reference to another formula, click Step In to display the other formula in the Evaluation box. Click Step Out to go back to the previous cell and formula.
Continue until each part of the formula has been evaluated.
More Info: Evaluate a nested formula one step at a time.
With a evaluation you see which part of your function returns which value. So you can easily see which Match function returns a value and which one fails because of no match.
Explanation of your debug result:
=INDEX('CoverLOG'!$e$1:$AR$89,3,68)
The above Index formula means get row 3 and column 68 of range $e$1:$AR$89 in sheet CoverLOG.
If we now analyze the range $e$1:$AR$89 it has 89 rows and 40 columns. You can test this with the following formulas:
=ROWS($E$1:$AR$89) '=89
=COLUMNS($E$1:$AR$89) '=40
but you try to access column 68 which exceeds the range total columns that is only 40 columns.

Obtain group average for numerous groups that vary in size

I get the feeling this is close to impossible, but here goes. I have data structured like this:
Test Group 1
pass
fail
pass
fall
Test Group 2
pass
fail
Test Group 3
pass
fail
fail
pass
I want to be able to paste it into Excel and have Excel summarise the percentage of each test group. So it would end up looking like this:
Test Group 1 Percentage Pass: 50%
pass
fail
pass
fall
Test Group 2 Percentage Pass: 50%
pass
fail
Test Group 3 Percentage Pass: 50%
pass
fail
fail
pass
BUT as you can see the test group length is not set, and it may vary. I was hoping is that I might be able to create a formula that follows this logic:
if( A<n> contains "Test")
count A<n> +1 until A<n> contains "Test"
It seems like I'm asking a lot from Excel formulas. I have spent some of today writing a small C# app that will split the configs into separate files so that I could copy and paste separate files into Excel. But it would be great to have fewer steps!
--- UPDATE ----
There were three very interesting approaches to this problem proving nothing is impossible :p
I wanted a solution that allowed me to copy and paste results in and see a load of percentages pop up so I was always sort of looking for a formula solution HOWEVER, please take the time to look at pnuts and Jerrys answers as they reveal some useful features of Excel!
chuffs answer was the one I was looking for and it worked out of the box. For anyone who wants to delve deep into how it works and why, I broke the formula down into steps and filled in some help information. The key to these formulas is combining MATCH, OFFSET and the slightly more obvious SEARCH / FIND / LEFT (I used to use IFERROR(FIND type approach, LEFT seems cleaner :) )
Do look at the documentation for these formulas but to see it all in action with some examples see the Google Spreadsheets I created detailing chuffs answer:
https://docs.google.com/spreadsheet/ccc?key=0AqODI11eAjtldDhDd2dBcFhpZW9SXzEybGtMUWMwM3c#gid=0
---P.S---
For the record I did actually create a C++ program to prettify my data and ouput it as .csv files. If I had had this info I wouldn't have bothered but am glad I tried both routes, it was a fun learning adventure.
A single, array-formula solution to this problem is possible. It requires only that a stop value "Test" be added at the bottom of your column of data.
Assuming your data are in the range A2:A18, here is the formula that would compute the average in cell B2:
=IF(LEFT(A1,4)="Test",
COUNTIF(OFFSET(A1,1,0,MATCH("Test*",$A2:$A$18,0)-1,1),"pass")
/ COUNTA(OFFSET(A1,1,0,MATCH("Test*",$A2:$A$18,0)-1,1)),
"")
The key parts of the formula are expressions that calculate the ranges for the two count functions, COUNTIF and COUNTA.
The COUNTIF function - which counts the number of passes in a group - takes two arguments, the range for the count and the condition to be met by cells counted.
I use the OFFSET function to provide the count range. OFFSETtakes five arguments:
An anchor cell (if a range is provided, the function only uses the top left cell in the range).
The number of rows below (+) or above (-) the anchor cell that the range to be returned will begin.
The number of columns to the right (+) or left (-) of the anchor cell for the start of the return range.
The number of rows to return.
The number of columns to return.
For example, OFFSET(A1,5,2,4,1) will return the range C6:D9.
In the formula, the anchor cell is A1, the row offset is 1 and the column offset is 0, in other words, the start of the range to return is A2.
The number of rows to return is computed by the MATCH function. For the calculation of the average for the first test group, MATCH looks in the range A2:A18 for the row of the first cell that starts with the word 'Test'. A2 is the cell in the pass/fail column just below the cell that starts the test group.
The last cell in the column is A18, which has been added to the data and contains the word 'Test'. This prevents the formula from returning an error for the last test group. Otherwise, the match would return an error because it could not find another occurrence of Test beyond the start of the final group.
Also note that the anchor points for the match range, i.e., $A2:$A$18, leaves unanchored the row reference to the top of the range (the 2 in A2). That's so the range will adjust downward as the formula is copied down so as to find the next, not the previous, occurrence of 'Test'.
Finally, I decrease the number of return rows by 1 to exclude the Text that MATCH found, which belongs to the next group.
The COUNTA functions - which counts the total number of passes and fails in a group - uses the same OFFSET/MATCH expression to get the range for the group.
This is an array formula and so must be entered with the Control-Shift-Enter key combination. Copy the formula down to the bottom of the data (excluding the cell with the 'Test' stop value) to calculate the averages for each group.
For convenience, here is the formula without the breaks shown above. It can be directly pasted into the worksheet (remembering to confirm it with Control-Shift-Enter).
=IF(LEFT(A1,4)="Test",COUNTIF(OFFSET(A1,1,0,MATCH("Test*",$A2:$A$18,0)-1,1),"pass")/COUNTA(OFFSET(A1,1,0,MATCH("Test*",$A2:$A$18,0)-1,1)),"")
Basically Subtotal will meet the requirement, provided some fairly tedious layout adjustments are acceptable.
Preparation:
Assuming Test Group 1 is in A1, insert Row1 and ColumnA, with in A2 =IF(LEFT(B2,1)="T",B2,"") and in C2 =IFERROR(MATCH(B2,{"fail","pass"},0)-1,"") and both formulae copied down as required. (And change fall to fail in source!)
Subtotal:
Select A:C, Data > Outline – Subtotal, At each change in: (1) Test Group 1, Use function: Average, Add subtotal to: check (Column C), uncheck Summary below data, OK.
Tidy up:
1. Move A3:C3 to A1 and A2:C2 to A3.
2. Filter A:C and for ColumnB, Text Filters, Contains add Test, OK.
3. In C3 put ="Percentage Pass: "&C4*100&"%" and copy down to last row numbered in blue (should show #DIV/0!).
4. Highlight A:C for all the rows numbered in blue and embolden.
5. Hide ColumnA and, optionally, hide or delete Rows1:2.
6. Take off filter selection.
Hopefully with preparation as on the left the result would be similar to as shown on the right:
Example re comment to #Jerry's answer:
There are many ways to tackle this -- one possible easy solution is to add a column next to your pass/fail column that says (assuming column A):
=IF(A1="pass",100,0)
if you do that, then the average of those values would be equal to the percentage pass.

Resources