Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() hi can anyone please explain to me the operator precedence rule in this formula : This formula works as what i wanted: =IF(B510000,D5*50%,IF(B50,D5*25%,\"NO TAX\")) The above is the correct formula, my b5=4500, so my answer is 1125. The formula works. but i tried to experiment using the following: *=IF(B510000,B5*50%,IF(*10000B50*,B5*25%,"No Tax")) *----this works,displays 1125 * =IF(B510000,B5*50%,IF(*0<B5<10000*,B5*25%,"No Tax"))* ----this doesn't work, displays no tax. hope someone can explain it to me ..thank you very much. i know this is something about precedence but i need more details about this. -- SFH ------------------------------------------------------------------------ SFH's Profile: http://www.excelforum.com/member.php...o&userid=32512 View this thread: http://www.excelforum.com/showthread...hreadid=522999 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi
If you want more than one test within an IF formula, use AND() or OR(). For example: =IF(B510000,B5*50%,IF(AND(B50,B5<10000),B5*25%," No Tax")) Hope this helps. Andy. "SFH" wrote in message ... hi can anyone please explain to me the operator precedence rule in this formula : This formula works as what i wanted: =IF(B510000,D5*50%,IF(B50,D5*25%,\"NO TAX\")) The above is the correct formula, my b5=4500, so my answer is 1125. The formula works. but i tried to experiment using the following: *=IF(B510000,B5*50%,IF(*10000B50*,B5*25%,"No Tax")) *----this works,displays 1125 * =IF(B510000,B5*50%,IF(*0<B5<10000*,B5*25%,"No Tax"))* ----this doesn't work, displays no tax. hope someone can explain it to me ..thank you very much. i know this is something about precedence but i need more details about this. -- SFH ------------------------------------------------------------------------ SFH's Profile: http://www.excelforum.com/member.php...o&userid=32512 View this thread: http://www.excelforum.com/showthread...hreadid=522999 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
"SFH" wrote:
can anyone please explain to me the operator precedence rule in this formula : [....] =IF(B510000,B5*50%,IF(10000B50,B5*25%,"No Tax")) ----this works,displays 1125 =IF(B510000,B5*50%,IF(0<B5<10000*,B5*25%,"No Tax")) ----this doesn't work, displays no tax. Someone else answered the "real" question, namely: what is the correct way to express "a b c". But to answer your question .... The first case is evaluated as "(10000 B5) 0". "(10000 B5)" results in a boolean value of true or false, which has a numerical value of 1 or 0 respectively. Therefore, the expression becomes "1 0" or "0 0", which coincidentally is true or false when "(10000 B5)" is true or false. But note that this does behave as you intended when B5 <= 0. In that case "10000 B5 0" will be true(!). The second case is evaluated as "(0 < B5) < 10000". "(0 < B5)" results in true (1) or false (0). So the expression becomes "1 < 0" or "0 < 0", which is always false(!). |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Jumping in to clarify something in joeu's explanation:
10000B50 is indeed first evaluated as (10000 85) 0. However, the expression in parentheses returns True or False, not 0 or 1. Thus, the final evaluation compares a T/F with a 1/0. Excel here provides a two-faced behavior: In *arithetic* expressions, True is implicitly converted to 1 and False is converted to 0. Yet, when doing explicit comparison, i.e. in *logical* expressions, True and False are considered larger than any number and TrueFalse. Thus: =1<FALSE -------will return TRUE =FALSE<TRUE --------- will return TRUE HTH Kostis Vezerides |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
"vezerid" wrote:
Jumping in to clarify something in joeu's explanation: 10000B50 is indeed first evaluated as (10000 85) 0. However, the expression in parentheses returns True or False, not 0 or 1. [....] True and False are considered larger than any number Thanks for the correction. I admit that I am used to a reasonable language like C, and I ass-u-me-d that Excel followed suit. It's a moot point now, but another comment to correct .... I wrote: "But note that this does behave as you intended when B5 <= 0." I meant to write: "does __not__ behave". But based on vezerid's comment, "(10000 B5) 0" does not even work as you intended when B5 = 10000. |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() thank you to all of you for clarifying the question i asked. Thanks for your time and help. Hana Singapore -- SFH ------------------------------------------------------------------------ SFH's Profile: http://www.excelforum.com/member.php...o&userid=32512 View this thread: http://www.excelforum.com/showthread...hreadid=522999 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
explanation of various fields on financial templates | New Users to Excel | |||
Counting or Total Formulas -- Further Explanation | Excel Worksheet Functions | |||
Has anyone had formulas change automatically with no explanation? | Excel Worksheet Functions | |||
Can I make pop up explanation boxes in Excel | Excel Discussion (Misc queries) | |||
Explanation for Excel message "no more fonts may be applied"? | Excel Discussion (Misc queries) |