Excel Nested IF statement with various text conditions - excel

I am creating IF statements in Excel to budget according to the discipline of engineers. I want:
IF(H5="CIVIL") then print for me value (I5*5000)
IF(H5="ARCHITECT") then print for me value (I5*3000)
IF(H5="ELECTRIC") then print for me value (I5*3000)
IF(H5="MECHANIC") then print for me value (I5*2000)
I am using a nested IF statement:
=IF(H5="CIVIL",I5,I5*5000,IF(H5="ARCHITECT",I5,I5*3000,IF(H5="ELECTRIC",I5,I5*3000,IF(H5="MECHANIC",I5,I5*2000))))
but I see the message "You've entered too many arguments for this function".
How can I use the formula without any problem?

Please try:
=IF(H5="CIVIL",5000,IF(OR(H5="ARCHITECT",H5="ELECTRIC"),3000,2000))*I5

There will be more professions with more values, so a "single formula" approach is second best. You should use a table with profession and value, and use VLOOKUP, then you can change values and add professions as you like without updating spaghetti formula code ... e.g.
A B
1 Civil 5000
2 Arch 3000
3 Elec 3000
4 Mech 2000
Specifying a profession in H5, you would use the following formula in I5:
=VLOOKUP(H5,A1:B4,2,FALSE)
Looking at your edit ... one more reason NOT to hide the unit cost in a formula, because in 2016 the rates might be different --> use a table!

You can always open your formula in a text editor and check it. I use line breaks to separate arguments. If you don't comment like I did you can even reimplement the now formatted formula. Saved me a lot of times.
Also, I've found your formula's hiatus:
=IF(
H5="CIVIL", 'test
I5, 'If True
I5*5000, 'If False
IF( 'WAT
H5="ARCHITECT",
I5,I5*3000,IF(H5="ELECTRIC",I5,I5*3000,IF(H5="MECHANIC",I5,I5*2000))))

Related

How to get the max value

I am trying to get the max value:
Here, Catee has 3 entries and out of which I need to highlight the maximum value which is 2000
Ramox has 4 entries and need to highlight the max value i.e. 144
I tried with condition formatting but I've more than 1900 rows plus 112+ records as like Catee and Ramox and applying condition formatting individually is a cumbersome process.
Record Ace has 550 as the highest number but appeared thrice. In this case, I need highlight them all
If there a better way to highlight the same:
Thanks!
Make it easy on yourself. My advise:
Select C2:C22;
Add conditional formatting rule based on: =C2=MAXIFS(C$2:C$22,A$2:A$22,A2);
Now, select A2:C22;
Hit F5;
Select: 'Special' >> 'Blanks' >> 'OK';
Type =A2 and confirm with Ctrl+Enter.
Are you aware of the Subtotals feature of Excel?
First, I'd advise you to add the names, as so beautifully explained in JvdV's video.
As a result, you get something like this:
Start the SubTotals feature, using the Max function:
The first result looks as:
Clicking on 2 in the margin modifies this into:
Have fun :-)

Combining multiple IF-statements into one formula

I am constructing a formula to act as an extra 'control cell' for my excel worksheet.
The if statements in text with the expected result:
If D2=0 and E2=0 and F2=0 =>""
If D2=0 and E2>0 and F2=0 =>"m of m2"
If D2>0 and E2>0 and F2=0 =>"m2 of m3"
If D2>0 and E2>0 and F2>0 =>"m3"
If D2>0 and E2=0 and F2>0 =>"m2"
If D2=0 and E2>0 and F2>0 =>"m2 of m3"
If D2=0 and E2=0 and F2>0 =>"m"
If D2>0 and E2=0 and F2=0 =>"m"
I'll converting this formula to vba afterwards, but my knowledge of vba is pretty limited so I like to start with just the excel formula.
Thanks in advance.
*edit: so far the formula always returns "m3" so it acts like all the cells are >0 even if they are empty/have a 0 value.
Formula so far (it's in dutch so als=if)
=ALS(D3=0&E3=0&F3=0;"";ALS(D3=0&E3>0&F3=0;"m of m2";ALS(D3>0&E3>0&F3=0;"m2 of m3";ALS(D3>0&E3>0&F3>0;"m3";ALS(D3>0&E3=0&F3>0;"m2";ALS(D3=0&E3>0&F3>0;"m2 of m3";ALS(D3=0&E3=0&F3>0;"m";ALS(D3>0&E3=0&F3=0;"m";""))))))))```
One way to interpret your table of results is that the value is equal to 0 or its not. your table does not cover the possibility of of values being less than 0. With this understanding one possible NESTED IF function would be:
=IF(D2=0,IF(E2=0,IF(F2=0,"","m"),IF(F2=0,"m of m2","m2 of m3")),IF(E2=0,IF(F2=0,"m","m2"),IF(F2=0,"m2 of m3","m3")))
Alternatively in excel you could use the CHOOSE function. Since each result is unique and its based based on binary results you could use the following formula to generate an index number from 1 to 8:
1+(F2>0)+(E2>0)*2+(D2>0)*4
Drop that in a CHOOSE function and its much more shorter manageable then nested IF. It could look as follows:
=CHOOSE(1+(F2>0)+(E2>0)*2+(D2>0)*4,"","m","m of m2","m2 of m3","m","m2","m2 of m3","m3")
now not being a VBA guru either, I am not sure how CHOOSE would translate over to VBA. But that would be another question!
UPDATE: ALTERNATE IF function
=IF(AND(D2=0,E2=0,F2=0),"",IF(AND(E2=0,D2<>F2),"m",IF(AND(D2=0,E2>0,F2=0),"m of m2",IF(AND(E2>0,D2<>F2),"m2 of m3",IF(AND(D2>0,E2=0,F2>0),"m2","m3")))))
There are many ways to go through the logic. In this case I was able to group the IF functions by results.

Can I use Rank with a non-continuous reference?

The rank formula needs the following variables: number, ref, and [order]
Does the ref have to be continuous?
Example: My ref is in cells A1-C1, however I have another number in another workbook that I want to add to that ref. I have a formula right now.
Here's the background:
We test for various chemicals and depending on the ppm value we take no action, note but no action, minor action, and major action.
Example:
- less than 3ppm then no action
- less than 6 but more than 3 no action but take notes
- less than 10 but more than 6 is minor action etc.
I need to know where my value lies in these tiers. The values in the tiers vary from .0001 to 100000.
Formulas are preferred, VBA will work too but no one else knows VBA so I think a formula will be easier for them and me to troubleshoot
Yes it is possible to Rank records which are not in single sheet.
Through this example I would like to show how to achieve it. Suppose you have 3 worksheet. First you need to Name them like,
={"Class1!$E$2:$E$5","Class2!$B$2:$B$5","Class3!$B$8:$B$11"}
and then after use this formula,
=IF(SUMPRODUCT(COUNTIF(INDIRECT(Score),E2))=0,"N/A",SUMPRODUCT(COUNTIF(INDIRECT(Score),">"&E2))+1).
NB : Score is the name given to the Data Ranges above.

Excel IFS formula - range of number

I have a value in cell AB8 and I want to conditionally return a status depending on which value it takes between 1 and 30.
I want to save time and rather than type the scores 1-9 indivdually to turn into "EMERGING" (etc) is there a way I can put a range in?
IFS(AB8=1,"EMERGING",AB8=2,"EMERGING",AB8=3,"EMERGING",AB8=4,"EMERGING",AB8=5,"EMERGING",AB8=6,"EMERGING",AB8=7,"EMERGING",AB8=8,"EMERGING",AB8=9,"DEVELOPING",AB8=10,"DEVELOPING",AB8=11,"DEVELOPING",AB8=12,"DEVELOPING",AB8=13,"DEVELOPING",AB8=14,"DEVELOPING",AB8=15,"DEVELOPING",AB8=16,"DEVELOPING",AB8=17,"SECURING",AB8=18,"SECURING",AB8=19,"SECURING",AB8=20,"SECURING",AB8=21,"SECURING",AB8=22,"SECURING",AB8=23,"SECURING",AB8=24,"SECURING",AB8=25,"READY",AB8=26,"READY",AB8=27,"READY",AB8=28,"READY",AB8=29,"READY",AB8=30,"READY")
Try this:
=INDEX({"EMERGING","DEVELOPING","SECURING","READY"},MATCH(AB8,{0,9,17,25},1))
Or create this table in, say, A1:B4:
0 Emerging
9 Developing
17 Securing
25 Ready
And then the formula is just:
=INDEX($B$1:$B$4,MATCH(AB8,$A$1:$A$4,1))
CallumDA's answer is more clean.
But this can be accomplished with nested IF formulas.
=IF(AB8>=1,IF(AB8<=8,"EMERGING",IF(AB8<=16,"DEVELOPING",IF(AB8<=24,"SECURING",IF(AB8<=30,"READY")))))
This one might also work,
=IF(AND(AB8>=1,AB8<=8),"EMERGING",IF(AND(AB8>=9,AB8<=16),"DEVELOPING",IF(AND(AB8>=17,AB8<=24),"SECURING",IF(AB8<=30,"READY","INVALID NUMBER"))))

How do I calculate a Sum based on multiple If's in Excel?

Background is that I'm making a budget spreadsheet. I have different bills due on different days. (ie. bill due on Monday and bill due on the 10th)
I want a function that will place the appropriate amount of money going in/out in column D and the description of why the money is going in/out in column E.
Currently I have two different formulas that I created (probably incorrectly).
Formula for Column E: (Already is in the document and seems to work fine other than that fact that I cant add additional text to the cell)
=IF(DAY(C36)=7," Amy Pay","")&IF(DAY(C36)=22," Amy Pay","")&IF(DAY(C36)=8," Family Bills","")&IF(DAY(C36)=6," Dollar Shave Club","")&IF(DAY(C36)=2," Amy Cap One VISA","")&IF(DAY(C36)=3," Chase VISA","")&IF(DAY(C36)=8," Being Smart","")&IF(DAY(C36)=17," Gym","")&IF(DAY(C36)=11," Netflix","")&IF(DAY(C36)=19," Cap One MC","")&IF(DAY(C36)=29," CenturyLink","")&IF(DAY(C36)=6," Haley Cap One Visa","")&IF(DAY(C36)=10," SRP","")&IF(DAY(C36)=23, "Car Payment","")&IF(DAY(C36)=30, "Rent","")&IF((B36)="Mon"," Monday","")&IF((B36)="Fri"," Friday","")&IF((B36)="Fri"," Haley Pay","")
Formula for Column D: (not in the column yet, as it doesn't work how I want)
=IF(DAY(B40)=7,"1474.22","")&IF(DAY(B40)=22,"1474.22","")&IF(DAY(B40)=8,"-100","")&IF(DAY(B40)=6,"-9","")&IF(DAY(B40)=2,"-100","")&IF(DAY(B40)=3,"-100","")&IF(DAY(B40)=8,"-400","")&IF(DAY(B40)=17,"-20.05","")&IF(DAY(B40)=11,"-8.63","")&IF(DAY(B40)=19,"-450","")&IF(DAY(B40)=29,"-50","")&IF(DAY(B40)=6,"-150","")&IF(DAY(B40)=10,"-200","")&IF(DAY(B40)=23,"-325","")&IF(DAY(B40)=30,"-500","")&IF((A40)="Mon","-125","")&IF((A40)="Fri","-325","")&IF((A40)="Fri","400","")
http://imgur.com/IBINweh
      
The problem is that in column D, rather than providing a sum of the numbers, it lists the numbers in the column.
http://imgur.com/rPDS5h2
      
I had a suggestion to add =SUM( in front of the IF( function, but when I do, #VALUE! is what results in the field. Using this formula: (view image by changing appended text to /CVs0f1v )
=SUM(IF(DAY(B40)=7,"1474.22","")&IF(DAY(B40)=22,"1474.22","")&IF(DAY(B40)=8,"-100","")&IF(DAY(B40)=6,"-9","")&IF(DAY(B40)=2,"-100","")&IF(DAY(B40)=3,"-100","")&IF(DAY(B40)=8,"-400","")&IF(DAY(B40)=17,"-20.05","")&IF(DAY(B40)=11,"-8.63","")&IF(DAY(B40)=19,"-450","")&IF(DAY(B40)=29,"-50","")&IF(DAY(B40)=6,"-150","")&IF(DAY(B40)=10,"-200","")&IF(DAY(B40)=23,"-325","")&IF(DAY(B40)=30,"-500","")&IF((A40)="Mon","-125","")&IF((A40)="Fri","-325","")&IF((A40)="Fri","400",""))
Any ideas on how I can get all the to populate and sum appropriately?
Forgive my Non Excel Guru knowledge - trying to learn. :D
-Amy
If you take all of the options from your first working formula and change the method retrieving them, you will have a much more versatile worksheet that can easily accept new additions and schedule modifications.
    
In a couple of unused columns to the right, pit in the day-of-month and the action that occurs. I'm using columns Y & Z. You have two events occurring on the 6th so I put them together.
In a couple of other unused columns use the day-of-the-week and associated text.; I've used columns V & W. The default for Sunday is 1.
In E36 use this formula,      =TRIM(IFERROR(VLOOKUP(DAY(C36),$Y:$Z, 2, FALSE), "")&" "&IFERROR(VLOOKUP(WEEKDAY(C36),$V:$W, 2, FALSE), "")) 
Fill down as necessary.
If you want the day-of-the-week in column B, use =C36 and use a custom number format of ddd or dddd.
References:
  VLOOKUP function  WEEKDAY function
You are concatenating text strings that look like numbers. You probably want to be adding real numbers:
=SUM(IF(DAY(B40)=7,1474.22,0) + IF(DAY(B40)=22,0) + ...
although, whenever I see a formula as complex as what you have, I would consider looking for a different solution -- Vlookup comes to mind.
In addition, with a VLOOKUP table, you would have seen that you have some conflicts -- e.g: you list the same condition of B40=8 to return two different values; and the same condition of A40 = Fri, to also return two different values.

Resources