SOLVED

Issue with IFS Statement Generation

%3CLINGO-SUB%20id%3D%22lingo-sub-1511861%22%20slang%3D%22en-US%22%3EIssue%20with%20IFS%20Statement%20Generation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1511861%22%20slang%3D%22en-US%22%3E%3CP%3EHello!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20create%20a%20budget%20and%20I've%20got%20some%20categories%20that%20determine%20what%20percent%20of%20my%20paycheck%20is%20going%20to%20go%20toward%20that%20savings%20category.%20I'm%20using%20an%20IFS%20statement%20to%20check%20all%20of%20the%20conditions%2C%20but%20I%20keep%20getting%20an%20error%20that%20tells%20me%20there's%20a%20problem%20with%20the%20formula%2C%20followed%20by%2C%20%22Not%20trying%20to%20type%20a%20formula%3F%20When%20the%20first%20character%20is%20an%20equal%20(%3D)%20or...%22%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EWhat%20I%20want%20this%20formula%20to%20do%20is%20check%20to%20see%20if%20my%20input%20of%20paycheck%20amount%20is%20within%20a%20range%20of%20%24200%20to%20%24299.99.%20If%20those%20conditions%20are%20met%2C%20then%20the%20formula%20multiplies%20my%20input%20by%20the%20percentage%20in%20the%20column%20next%20to%20it%20that%20I%20have%20chosen%20to%20take%20out%20and%20put%20into%20savings.%20The%20formula%20that%20I%20have%20created%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIFS(B20%26lt%3B%3DA4%26amp%3B(A5-0.01)%2C((B20*B4)*4))%2C%20(B20%26lt%3B%3DA5%26amp%3B(A6-0.01)%2C((B20*B5)*4))%2C%20(B20%26lt%3B%3DA6%26amp%3B(A6-0.01)%2C((B20*B6)*4))%2C%20(B20%26lt%3B%3DA7%26amp%3B(A7-0.01)%2C((B20*B6)*4))%2C%20(B20%26lt%3B%3DA8%26amp%3B(A8-0.01)%2C((B20*B7)*4))%2C%20(B20%26lt%3B%3DA9%26amp%3B(A9-0.01)%2C((B20*B8)*4))%2C%20(B20%26lt%3B%3DA10%26amp%3B(A10-0.01)%2C((B20*B9)*4))%2C%20(B20%26lt%3B%3DA11%26amp%3B(A11-0.01)%2C((B20*B10)*4))%2C%20(B20%26lt%3B%3DA12%26amp%3B(A12-0.01)%2C((B20*B11)*4))%2C%20(B20%26lt%3B%3DA13%26amp%3B(A13-0.01)%2C((B20*B12)*4))%2C%20(B20%26lt%3B%3DA14%26amp%3B(A14-0.01)%2C((B20*B13)*4))%2C%20(B20%26lt%3B%3DA15%26amp%3B(A15-0.01)%2C((B20*B14)*4))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20have%20I%20done%20wrong%3F%20I've%20attached%20a%20screenshot%20of%20the%20spreadsheet%20and%20formula%20I%20attempted%20to%20create.%20I'm%20almost%20positive%20that%20the%20formulas%20work%20individually.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1511861%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1511905%22%20slang%3D%22en-US%22%3ERe%3A%20Issue%20with%20IFS%20Statement%20Generation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1511905%22%20slang%3D%22en-US%22%3EJust%20off%20the%20cuff%2C%20note%20that%20the%20%26amp%3B%20is%20for%20concatenating%20two%20strings%2C%20not%20for%20a%20conditional%20test.%20And%20the%20result%20will%20be%20text%2C%20not%20numeric%20value.%3CBR%20%2F%3E%3CBR%20%2F%3ESay%20B20%3D20%2C%20A4%3D25%2C%20and%20A5%3D30.%3CBR%20%2F%3E%3CBR%20%2F%3EB20%26lt%3B%3DA4%26amp%3B(A5-0.01)%20will%20give%20the%20result%3A%2020%26lt%3B%3D%222529.99%22%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20Excel%20text%20values%20are%20always%20greater%20than%20numerical%20values.%20Since%20%222529.99%22%20is%20text%20your%20test%20will%20always%20be%20TRUE.%3CBR%20%2F%3E%3CBR%20%2F%3EAND(B20%26lt%3B%3DA4%2C%20B20%26lt%3B%3DA5)%20is%20what%20you%20would%20use%20if%20you%20are%20testing%20whether%20or%20not%20b20%20is%20less%20than%2Fequal%20to%20both%20A4%20and%20A5.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1511914%22%20slang%3D%22en-US%22%3ERe%3A%20Issue%20with%20IFS%20Statement%20Generation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1511914%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F723650%22%20target%3D%22_blank%22%3E%40carter375%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%20formula%20could%20be%20optimised%2C%20but%20at%20least%20such%20components%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EB20%26lt%3B%3DA4%26amp%3B(A5-0.01)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eare%20not%20correct.%20What%20do%20you%20mean%20by%20this%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1512043%22%20slang%3D%22en-US%22%3ERe%3A%20Issue%20with%20IFS%20Statement%20Generation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1512043%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20this%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EB20%26lt%3B%3DA4%26amp%3B(A5-0.01)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EI%20am%20trying%20to%20say%20if%20the%20entered%20amount%20in%20B20%20is%20less%20than%20or%20equal%20to%20A4%20and%20less%20than%20or%20equal%20to%20A5-0.01%2C%20which%20is%20part%20of%20the%20range%20my%20conditions%20are%20based%20on.%20If%20the%20tail%20end%20of%20my%20range%20was%20equal%20to%20A5%20and%20not%20A5-0.01%2C%20I%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1512103%22%20slang%3D%22en-US%22%3ERe%3A%20Issue%20with%20IFS%20Statement%20Generation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1512103%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F723650%22%20target%3D%22_blank%22%3E%40carter375%3C%2FA%3E%26nbsp%3B%20OK%20I%20think%20there%20are%20a%20couple%20problems%20with%20that%20formula%20the%20foremost%20being%20that%20I%20believe%20you%20can%20do%20it%20much%20easier.%26nbsp%3B%20As%20for%20the%20issues%20with%20the%20formula%3A%3C%2FP%3E%3CUL%3E%3CLI%3Ethe%20formula%20is%20trying%20to%20check%20a%20range%20and%20then%20multiply%20by%20the%20'lower'%20row%20but%20you%20references%20to%20your%20%22range%22%20change%20from%20A4%26amp%3B(A5-0.01)%20to%26nbsp%3BA15%26amp%3B(A15-0.01)%26nbsp%3B%3C%2FLI%3E%3CLI%3EThis%20%22range%22%20is%20not%20doing%20what%20you%20think%3A%26nbsp%3BA4%26amp%3B(A5-0.01)%20will%20combine%20them%20like%20text%20and%20create%20a%20number%207079.99%3C%2FLI%3E%3CLI%3EAround%20A6%20and%20A7%20you%20start%20referring%20to%20the%20row%20even%20before%20the%20'lower'%20row%3C%2FLI%3E%3CLI%3Eas%20for%20why%20you%20are%20getting%20the%20error%2C%20could%20be%20doing%20a%20%22%26lt%3B%3D%22%20comparison%20to%20a%20text%20value%20that%20maybe%20couldn't%20get%20converted%20to%20a%20number%20or%20some%20other%20ref.%20but%20I%20didn't%20track%20that%20down%3C%2FLI%3E%3C%2FUL%3E%3CP%3ENow%20for%20the%20good%20news.%26nbsp%3B%20You%20can%20(and%20should)%20do%20this%20much%20easier%20using%20VLOOKUP%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%24B%2420*VLOOKUP(%24B%2420%2C%24A%244%3A%24B%2414%2C2)*4%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20works%20for%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello!

 

I'm trying to create a budget and I've got some categories that determine what percent of my paycheck is going to go toward that savings category. I'm using an IFS statement to check all of the conditions, but I keep getting an error that tells me there's a problem with the formula, followed by, "Not trying to type a formula? When the first character is an equal (=) or..." 


What I want this formula to do is check to see if my input of paycheck amount is within a range of $200 to $299.99. If those conditions are met, then the formula multiplies my input by the percentage in the column next to it that I have chosen to take out and put into savings. The formula that I have created is:

 

=IFS(B20<=A4&(A5-0.01),((B20*B4)*4)), (B20<=A5&(A6-0.01),((B20*B5)*4)), (B20<=A6&(A6-0.01),((B20*B6)*4)), (B20<=A7&(A7-0.01),((B20*B6)*4)), (B20<=A8&(A8-0.01),((B20*B7)*4)), (B20<=A9&(A9-0.01),((B20*B8)*4)), (B20<=A10&(A10-0.01),((B20*B9)*4)), (B20<=A11&(A11-0.01),((B20*B10)*4)), (B20<=A12&(A12-0.01),((B20*B11)*4)), (B20<=A13&(A13-0.01),((B20*B12)*4)), (B20<=A14&(A14-0.01),((B20*B13)*4)), (B20<=A15&(A15-0.01),((B20*B14)*4))

 

What have I done wrong? I've attached a screenshot of the spreadsheet and formula I attempted to create. I'm almost positive that the formulas work individually.

4 Replies
Just off the cuff, note that the & is for concatenating two strings, not for a conditional test. And the result will be text, not numeric value.

Say B20=20, A4=25, and A5=30.

B20<=A4&(A5-0.01) will give the result: 20<="2529.99"

In Excel text values are always greater than numerical values. Since "2529.99" is text your test will always be TRUE.

AND(B20<=A4, B20<=A5) is what you would use if you are testing whether or not b20 is less than/equal to both A4 and A5.

@carter375 

Perhaps formula could be optimised, but at least such components as

B20<=A4&(A5-0.01)

are not correct. What do you mean by this?

 

@Sergei Baklan 

 

By this 

B20<=A4&(A5-0.01)

I am trying to say if the entered amount in B20 is less than or equal to A4 and less than or equal to A5-0.01, which is part of the range my conditions are based on. If the tail end of my range was equal to A5 and not A5-0.01, I 

Best Response confirmed by carter375 (New Contributor)
Solution

@carter375  OK I think there are a couple problems with that formula the foremost being that I believe you can do it much easier.  As for the issues with the formula:

  • the formula is trying to check a range and then multiply by the 'lower' row but you references to your "range" change from A4&(A5-0.01) to A15&(A15-0.01) 
  • This "range" is not doing what you think: A4&(A5-0.01) will combine them like text and create a number 7079.99
  • Around A6 and A7 you start referring to the row even before the 'lower' row
  • as for why you are getting the error, could be doing a "<=" comparison to a text value that maybe couldn't get converted to a number or some other ref. but I didn't track that down

Now for the good news.  You can (and should) do this much easier using VLOOKUP:

=$B$20*VLOOKUP($B$20,$A$4:$B$14,2)*4

 

Hope that works for you.