Pages: [1]   Go Down
Print
Author Topic: Anyone good with booleans?  (Read 2235 times)
Samdy Gray
Dirty sneaky traitor weasel

Offline Offline

Posts: 27183





Ignore
« on: Tuesday, June 17, 2008, 17:14:01 »

I'm using Excel to work something out and I'm sure there's a simpler way of doing this formula, but can't seem to get my brain in gear:

Code:
=IF(AND($C$3>$D$3,$C7>$D7),2,IF(AND($C$3<$D$3,$C7<$D7),2,IF(AND($C$3=$D$3,$C7=$D7),2,0)))
Logged
axs
naaarrrrrppppp

Offline Offline

Posts: 13469





Ignore
« Reply #1 on: Tuesday, June 17, 2008, 17:16:58 »

couldn't you just use an IF statement with the product of d3 minus c3 etc?
Logged
Ralphy

Offline Offline

Posts: 14190





Ignore
« Reply #2 on: Tuesday, June 17, 2008, 18:28:52 »

Why would you want to work that out?!
Logged
donkey
Cheers!

Offline Offline

Posts: 7114


He headed a football.




Ignore
« Reply #3 on: Tuesday, June 17, 2008, 19:06:12 »

Quote from: "Samdy Gray"
I'm using Excel to work something out and I'm sure there's a simpler way of doing this formula, but can't seem to get my brain in gear:

Code:
=IF(AND($C$3>$D$3,$C7>$D7),2,IF(AND($C$3<$D$3,$C7<$D7),2,IF(AND($C$3=$D$3,$C7=$D7),2,0)))


It's a monkey eating a banana.
Logged

donkey tells the truth

I headed the ball.

eeeeeeeeeeeeeee-aaaaaaaawwwwwww
ron dodgers

Offline Offline

Posts: 2745


shaddap your face




Ignore
« Reply #4 on: Tuesday, June 17, 2008, 20:13:59 »

is it like COBOL where you would do an IF.. NOT.. OR jobby not sure of the syntax in Excel
Logged
Samdy Gray
Dirty sneaky traitor weasel

Offline Offline

Posts: 27183





Ignore
« Reply #5 on: Tuesday, June 17, 2008, 22:29:03 »

Any IF statement is the same really, just the syntax is slightly different between programming languages. Like for example Excel has the format "IF [logic], [value if true], [value if false]" whereas say in Visual Basic it's "IF [logic] THEN [value if true] ELSE [value if false]".

The statement I put in my first post does work though, I'm just sure there's probably a more efficient way to code it, hence my question.
Logged
Bushey Boy

Offline Offline

Posts: 8351





Ignore
« Reply #6 on: Tuesday, June 17, 2008, 22:33:09 »

Geek, thats all
Logged

axs
naaarrrrrppppp

Offline Offline

Posts: 13469





Ignore
« Reply #7 on: Tuesday, June 17, 2008, 22:37:33 »

Quote from: "Samdy Gray"
Any IF statement is the same really, just the syntax is slightly different between programming languages. Like for example Excel has the format "IF [logic], [value if true], [value if false]" whereas say in Visual Basic it's "IF [logic] THEN [value if true] ELSE [value if false]".

The statement I put in my first post does work though, I'm just sure there's probably a more efficient way to code it, hence my question.


I can't think of any better ways to write it other than using an IF for the product as stated or a NOT might be easier, but without seeing what you're working with it's a bit tricky.
Logged
Samdy Gray
Dirty sneaky traitor weasel

Offline Offline

Posts: 27183





Ignore
« Reply #8 on: Tuesday, June 17, 2008, 22:42:30 »

It's for the prediction league, trying to automate it in Excel to save me time. Trying to use the boolean for the 'correct outcome' scoring.

So for example, if the score was 3-0 and somebody predicted 2-0 I want it to add the value '2'. The '3' and the '0' are in seperate cells: C3 and D3. The predicted score is in C7 and D7.

But I've just seen a flaw in the code anway, so I think your product idea might be the only way that will work.
Logged
axs
naaarrrrrppppp

Offline Offline

Posts: 13469





Ignore
« Reply #9 on: Tuesday, June 17, 2008, 22:52:24 »

with that as the way it is and someone predicted 2-1 and it finished 2-3, they would get points when they shouldn't? or is that the flaw you talked of?
Logged
Samdy Gray
Dirty sneaky traitor weasel

Offline Offline

Posts: 27183





Ignore
« Reply #10 on: Tuesday, June 17, 2008, 22:54:34 »

That's the flaw I just saw, yes. So by doing the product one like this it should work (I think):

Code:
=IF(AND($C$3-$D$3=0,$C7-$D7=0),2,IF(AND($C$3-$D$3=<0,$C7-$D7=<0),2,IF(AND($C$3-$D$3=>0,$C7+$D7=>0),2,0)))
Logged
axs
naaarrrrrppppp

Offline Offline

Posts: 13469





Ignore
« Reply #11 on: Tuesday, June 17, 2008, 22:58:51 »

yes, assuming it was 2 points for correct result then that works.
Logged
@MacPhlea

Offline Offline

Posts: 2325





Ignore
« Reply #12 on: Wednesday, June 18, 2008, 06:27:25 »

I have a prediction league thing already made up in excel that I have used for the last 8 years for world and euro championships. you can download it below (you may need to unprotect the worksheet first if yu want to make changes to the format)

http://www.comptonbassett.com/euro2004.xls
Logged
Samdy Gray
Dirty sneaky traitor weasel

Offline Offline

Posts: 27183





Ignore
« Reply #13 on: Wednesday, June 18, 2008, 08:29:10 »

Top stuff, cheers.
Logged
Pages: [1]   Go Up
Print
Jump to: