How this Formula Works? - excel

I'm looking at a legacy spreadsheet and I cannot for the life of me figure out how this formula works. I'm by no means an excel wizard.
The spreadsheet tracks billing for a company for members of staff. On each row, the user puts an ID, the amount, and formula then puts the figure under a column for a given staff member.
And the formula:
=IF(A2="Foo",A2="Foo")*(SUM(B2))
I would have done this:
=IF(A2="Foo", B2, 0)
Which appears to have the same effect.
Any insight?

=IF(A2="Foo",A2="Foo") is equivalent to =A2="Foo". It results in a boolean value, which is used by the multiplication operation as 1 or 0.
I don't see any reason to express it that way instead of the more concise and intuitive formula that you offer.

The original formula has a lot of excess calculations going on in it. It can be simplified as you mentioned, which is what most people would do. Some alternate forms might be:
=(A2="Foo")*B2
The above formula you would place in D2 and copy down and then you would have to redo the String comparisson for column E then again for F. If you used the following formula you could place it in D2 and copy it down and to the right as needed without having to adjust the formula.
=($A2=D$1)*$B2
In more common terms it would look like
=IF($A2=D$1,$B2,0)

Related

Struggling to find formula to find if a certain words come up for the same account

The table above is an example. Lets say I only have Column 1 & 2 and want to create the yellow headers.
I'm trying to figure out a formula to look for the fruit and return a 1 if the header of that column can be matched to the fruit.
Once I figure that formula out I will then delete duplicates in column A and end with this:
I tried using something like Index and Match formula but that does not return the "1" on the same rows.
Usually the data is reversed and I can use countif but I'm lost on what formula to use.
Essential in cell C2, I want to find if C1 can be found in the B Column with Apple being the criteria. And the same for D2, E2, F2. It's hard to explain but I hope you understand.
This should be the formula you've been looking for. Enter it inC2 and copy right and down as far as required.
=COUNTIFS(INDEX(Data,,1),$A2,INDEX(Data,,2),C$1)
I'm using a range I called Data in the formula which comprises A2:B7 in your example. In real life you would make it dynamic or even replace INDEX(Data,,1) with $A:$A. It's a decision about quality, not functionality. In programming the better "quality" requires less time for maintenance. Therefore it's subjective.
The formula returns a lot of zeroes. You can get rid of them with cell formatting.
You can use pivot table for:
zz

Formula to sum the 5 cells and classify it based on the result

I am a beginner to the Excel formula Please help to build the excel formula to sum the values in the rows (Z13:AC13) and from the result classify the value based on the below Classifications.
Unlikely: >=4<6
Possible: >=6<9
Likely: >=9<12
Certain: >=12<=16
I tried the below code but it is not working:
=IF(OR(SUM(Z13:AC13)>=4,SUM(Z13:AC13)<6),"Unlikely"),IF(OR(SUM(Z13:AC13)>=6,SUM(Z13:AC13)<9),"Possible"),IF(OR(SUM(Z13:AC13)>=9,SUM(Z13:AC13)<12),"Likely"),IF(OR(SUM(Z13:AC13)>=12,SUM(Z13:AC13)<=16),"Certain")
Try:
=CHOOSE(MATCH(SUM(Z13:AC13),{4,6,9,12}),"Unlikely","Possible","Likely","Certain")
Scott's answer is better, but if you'd rather have a more complicated formula that uses fewer Excel concepts, this worked for me:
=IF(AND(total>=4,total<6),"unlikely",IF(AND(total>=6,total<9),"possible",IF(AND(total>=9,total<12),"likely",IF(AND(total>=12,total<=16),"certain","---"))))
"---" is there in case the total is ever >16 by accident.
I gave the cell containing the sum the range name total to make the formula a little easier to read. If you don't like that, substitute SUM(Z13:AC13) for total.
I think the problem with your formula is the parenthesis after (for instance), the word "unlikely". It messes up the nesting. You don't want
IF(OR(SUM(Z13:AC13)>=4,SUM(Z13:AC13)<6),"Unlikely"),IF(OR...
you just want
IF(OR(SUM(Z13:AC13)>=4,SUM(Z13:AC13)<6),"Unlikely",IF(OR...
Simpler example showing the substitution of a whole second IF statement for condition-if-false:
=IF(criterion,condition-if-true,condition-if-false)
=IF(criterion,condition-if-true,IF(criterion,condition-if-true,condition-if-false))
Try it for practice:
Cell A1: blank cell for data
Cell B1: enter the formula =IF(A1="a","a",IF(A1="b","b","neither"))
Then enter a, b, or c into A1 to see what happens in B1.
A good tip is if you're having trouble with a formula, abandon your real data for a minute and make a dummy example that's as simple as possible. Get that to work, and then substitute your real conditions one step at a time.

Trying to put together a packaging list from a spreadsheet in excel

Excel Example 1
In column A I have a list of order numbers. In columns B-F I have the different products and the number of orders each have placed for the product. How do I make it so that when I type in the order value into I1, it will return all cells with values into the cells below?
I believe it is an array that i need but not positive. This is just an example, I am trying to do this on a larger scale.
Try to use this formula, it should help or at least give you an idea.
=INDEX($B$2:$F$6,MATCH($I$1,$A$2:$A$6,0),MATCH($I2,$B$1:$F$1,0))
OK, it will be like this:
In I2 your formula is
=INDEX($A$1:$F$1,1,MATCH(TRUE,ISNUMBER(INDIRECT("A"&MATCH(I1,A:A,0)&":F"&MATCH(I1,A:A,0))),0))
In I3 your formula is
=INDEX($A$1:$F$1,1,MATCH(TRUE,ISNUMBER(INDIRECT("A"&MATCH(I1,A:A,0)&":F"&MATCH(I1,A:A,0)))*(A1:F1<>I2),0))
In I4 your formula should be
=INDEX($A$1:$F$1,1,MATCH(TRUE,ISNUMBER(INDIRECT("A"&MATCH(I1,A:A,0)&":F"&MATCH(I1,A:A,0)))*(A1:F1<>I2)*(A1:F1<>I3),0))
And there it goes...
For each cell below you will need to repeat the multiplication "(A1:F1<>Ix)" with every cell above, because it evaluates an array which will compare to the others and return the next true result that isn't any of the colors above neither is a color without value.
Every of those formulas are array formula (confirm them with ctrl+shift+enter). You probably know how to get the values in J, but just in case, it's:
=INDEX($A$1:$F$7,MATCH($I$1,A:A,0),MATCH($I2,$A$1:$F$1,0))
PS: my Excel is in portuguese so my arguments separator is ";", I did change them for "," here in this comment. Just in case the formula doesn't work for you, try to look for some ";" I may have missed, also pay some attention to the $$ because I didn't lock the I1 reference properly, still I hope this can help you.
Thanks everyone for your answers. I ended up going with a vlookup then set a quick macro to run auto-filtering based off conditional formatting. It was the cleanest way i could find to work with the large amount of data I had.

Excel formula checklist in employees

I want to know about this Excel formula and how it works
IFERROR(COUNTIF(OFFSET(T_E[[#Headers],[EMPLOYEE NAME]],MATCH(I_E,L_E,0),MATCH("ACT 1 DT",L_H,0)-1,1,N_S),">0")&" / "&N_S,"")
Please tell me about this formula and how can I change this by adding or removing.
The best for trying how function works is to try it in excel, but still...
You want to know what the whole function works or just how partial functions work?
In general, the function addresses to formatted table and to named parts of the table, so it should return value from formatted table, that is x rows from employee name in row and x columns from employee name in this row.
How many depends on what is under "I_E", "L_E" and "L_H" and "N_S", I cannot tell without this knowledge.
How to evaluate a formula
If you would like to better understand how a complex formula works, use the Formula Evaluator in Excel. Therefore select the cell that contains the formula, and on the Formulas tab, in the Formula Auditing group, click Evaluate Formula.
Also there is a documentation for all formula functions. With this and the Formula Evaluator you should be able to trace what the formula does.

EXCEL - Find category by searching keyword from other worksheet

I want to get sales by category (states).
In Sheet1, there're state's names in row A (A1 to A6) and cities in the column.
Each cities belongs to states,
e.g.
Sydney belongs to NSW, and Melbourne & Geelong belong to VIC.
Then Sheet2 contains sales data like shown below.
I want to calculate sales by state each month.
At the moment, each cells between row D and row I has a formula like below;
(e.g. F5)
=IF(AND(ISERR(SEARCH("Brisbane",B5)),ISERR(SEARCH("Gold Coast",B5)),ISERR(SEARCH("Cairns",B5))),"",C5)
But I'm sure there would be better and more simple nifty way to do this. As shops increase, this current formula gets more complicated. So it's needed to be optimized.
I would like to make these calculation simple using vlookup or something.. but no luck so far.
Any advice, detailed if possible, would be greatly appreciated! Thank you in advance :)
You can do this with an array formula. For example, in D3 use:
=IFERROR(IF(INDIRECT("Sheet1!A"&MAX(IF(ISERROR(SEARCH("*"&Sheet1!$B$1:$D$6&"*",$B3))+(Sheet1!$B$1:$D$6=""),0,ROW(Sheet1!$B$1:$D$6))))=D$1,$C3,""),"Not found")
(To enter an array formula, you need to press Ctrl+Shift+Enter)
The SEARCH looks at the store name in B3 and compares it to all names in Sheet1!B1:D6 with a * wildcard before and after. This won't be an error if it matches.
Adding the +(Sheet1!$B$1:$D$6="") gives an OR the cell is blank (otherwise ** would match).
If it isn't an error, we'll get the ROW of the corresponding match and we take the highest (MAX) row match.
We then use INDIRECT to get the cell value in column A of Sheet1 (the State code) and compare that to the state in the top row of our column
This is wrapped in an IFERROR to tell us if our store doesn't match any city
Array formulas are a great tool, but a little confusing! Rather than work on a single cell, array formulas work on each cell of an array. Typically this is for counts, sums, averages, etc. By including “logic maths”, you can do some really strange things in a single formula. A good resource is [link]http://www.cpearson.com/excel/arrayformulas.aspx Always remember to use Ctrl+Shift+Enter or really strange things will happen!

Resources