Whats wrong with th...
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

[Closed] Whats wrong with this formula?

20 Posts
12 Users
0 Reactions
72 Views
Posts: 0
Free Member
Topic starter
 

=IF(W2<=0.1,“0”,IF(W2>=0.1,W2<=9.99,”10”,IF(W2>=10.00,W2<=19.99,”20”,IF(W2>=20.00,W2<=29.99,”30”,IF(W2>=30.00,W2<=39.99,”40”,IF(W2>=40.00,W2<=49.99,”50”,IF(W2>=50.00,W2<=59.99,”60”,IF(W2>=60.00,W2<=69.99,”70”,IF(W2>=70.00,W2<=79.99,”80”,IF(W2>=80.00,W2<=89.99,”90”,IF(W2>=90.00,W2<=99.99,”100”,IF(W2>=100.00,”100+”,””))))))))))))

=IF(W2<=0.1,“0”,IF(W2>=0.1,W2<=24.99,”25”,IF(W2>=25.00,W2<=49.99,”20”,IF(W2>=50.00,W2<=74.99,”75”,IF(W2>=75.00,W2<=99.99,”100”,IF(W2>=100.00,”100+”,””))))))


 
Posted : 26/05/2020 4:00 pm
Posts: 3652
Full Member
 

That's two different formulae. Is the whole thing in one cell?


 
Posted : 26/05/2020 4:02 pm
Posts: 0
Free Member
Topic starter
 

Sorry, one to return a rounded up percentage range to allow for Pivot filters from 10-100+, and the other less ranges


 
Posted : 26/05/2020 4:05 pm
Posts: 0
Free Member
 

That it's horrible?

What exactly are you trying to do?

Also missing loads of and statements isn't it?


 
Posted : 26/05/2020 4:05 pm
Posts: 3652
Full Member
 

Can you just use this:
=IF(W2>100,"100+",ROUNDUP(W2,-1))

Edit:

That it’s horrible?

Well, yes!

Edit 2: I've had another look at it, there's so much unnecessary complication there.

e.g. the first chunk of it =IF(W2<=0.1,“0”,IF(W2>=0.1,W2<=9.99,”
The first if says if it's less than or equal to 0.1 then show zero. After the second comma should be the "if thats's not true" value. But you've got another if, to check if it's greater than or equal to 0.1, except it must be greater than 0.1 because it's failed the first part of the IF statement.

I think you'd need to use AND() to have multiple criteria in the IF. Except you don't need multiple criteria, because if it's failed the first check of "<=0.1" then it must be ">0.1" so you don't need to check again.


 
Posted : 26/05/2020 4:06 pm
Posts: 17273
Free Member
 

Too many IFs

You can only nest seven in one formula IIRC


 
Posted : 26/05/2020 4:07 pm
Posts: 0
Free Member
 

=if(w2>100,"100+",if(w2<0.1,0,roundup(w2/10,0)*10))

Should I think achieve what you're after

[edit]

You can only nest seven in one formula IIRC

14 I thought? but yeah, there's a limit


 
Posted : 26/05/2020 4:09 pm
Posts: 3729
Free Member
 

The fact that you can't tell what's wrong, well no-one will be able to quickly, says that you need to use a different function e.g. Vlookup rather than nested ifs.

You can only nest seven in one formula IIRC

14 I thought? but yeah, there’s a limit

It depends on the version. Prearchy is showing his age with the limit of 7. I think the current limit is 64 although frankly that's just stupid.


 
Posted : 26/05/2020 4:10 pm
Posts: 3652
Full Member
 

dangeourbrain
=if(w2>100,”100+”,if(w2<0.1,0,roundup(w2/10,0)*10))

Should I think achieve what you’re after

you can use "-1" in the ROUND/ROUNDUP/ROUNDDOWN formula to round to the nearest 10, -2 to 100, -3 to 1000 etc, no need to divide by 10 and multiply back up.


 
Posted : 26/05/2020 4:14 pm
Posts: 0
Free Member
 

Ahh, learn something new! Ta for that.

Though invariably I only have to do that sort of nonsense because people work in multiples of 25.4...


 
Posted : 26/05/2020 4:15 pm
Posts: 17273
Free Member
 

Perchy is showing his age with the limit of 7.

This database was all just empty fields when I were a lad


 
Posted : 26/05/2020 4:18 pm
Posts: 91000
Free Member
 

What's wrong with it? It's an impenetrable mess. Top programming tip: if something ends up hideously complicated you're using the wrong approach. There'll be a better method, go find it.


 
Posted : 26/05/2020 4:30 pm
Posts: 2642
Free Member
 

"=IF(W2<=0.1,“0”,IF(W2>=0.1,W2<=9.99,”10”,...."

As well as being terminally ugly, the 2nd parameter of the IF function (i.e. the bit in bold) should be the TRUE return value. (I suspect you intended IF(((W2>=0.1) AND (W2<=9.99)),...,...)

But as above, there are much, much neater ways of getting what you want.


 
Posted : 26/05/2020 4:56 pm
Posts: 0
Free Member
 

(I suspect you intended IF(((W2>=0.1) AND (W2<=9.99

Would be if(and(var1, var2, etc), true, false)


 
Posted : 26/05/2020 5:04 pm
Posts: 0
Free Member
Topic starter
 

Ok, i admit it, I need your help 🙂

In essence I have a range of varying values from 72.73% to 120% etc, I'm looking to set ranges that I can then just filter by, such as 0%, 25%, 50%, 75% 100% and 100+

=IF(AND(W2>=0.1,W2<=24.99),"25",IF(AND(W2>=25,W2<=49.99),"50", IF(AND(W2>=50,W2<=74.99),"75", IF(AND(W2>=75,W2<=99.99),"100",""))))


 
Posted : 26/05/2020 5:15 pm
Posts: 0
Free Member
Topic starter
 

Hi, decided to just use this, much easier, thanks for your help 🙂

=ROUND(W2,1)


 
Posted : 26/05/2020 5:37 pm
Posts: 1447
Full Member
 

Though invariably I only have to do that sort of nonsense because people work in multiples of 25.4…

So inches to millimetres then? You could just run it in inches and then convert to mm's at the end 😉


 
Posted : 26/05/2020 5:49 pm
Posts: 4954
Free Member
 

Try a vbscript. Anything that complicated in one cell will be impossible to alter / maintain in the future.


 
Posted : 26/05/2020 8:48 pm
Posts: 77347
Free Member
 

The first if says if it’s less than or equal to 0.1 then show zero. After the second comma should be the “if thats’s not true” value. But you’ve got another if, to check if it’s greater than or equal to 0.1, except it must be greater than 0.1 because it’s failed the first part of the IF statement.

Excel formulae construction and all other things aside, the core logic is screwed here because one of those two things shouldn't be an "or equals."


 
Posted : 26/05/2020 8:57 pm
Posts: 1318
Full Member
 

If you can't get a formula to get what you want (the with the rounding etc), look at the switch function instead of nested ifs.

It's much easier to get right and work out what it was meant to do when you look at it again a few days (minutes?) later.


 
Posted : 26/05/2020 9:00 pm
Posts: 1127
Free Member
 

I'll tell you whats wrong with it- no mention of a Skoda or a wood burner. Bloody idiots.


 
Posted : 27/05/2020 9:32 pm

6 DAYS LEFT
We are currently at 95% of our target!