Quick Question - If Calculation funtion Syntax

  • Follow


In

If (test;result1;result2)

is result2 if the test is false? and result 1 is if the test is true?
0
Reply Jennifer_Beecroft (79) 5/16/2012 7:17:30 AM

On Wed, 16 May 2012 00:17:30 -0700 (PDT), JayBee wrote:
>  If (test;result1;result2)
> 
>  is result2 if the test is false? and result 1 is if the test is true?

Wouldn't it be faster to just try it?

Yes, your assumption is correct - especially due to the syntax variation

  if (test; result1)

This is equal to 
  if (test; result1; "")

Later pro versions would permit custom functions:

  my()
    GetField( Get ( ActiveFieldName ) ))


  myif(test; result1)
    if(test, result1,
    my))

.... which would keep the current value if the if condition does not
match.

That's most helpful for a replace operation, 
although this replace operation is very dangerous within FMP, since
there's no advanced undo mechanism.

- Martin
0
Reply t-usenet (136) 5/16/2012 8:57:01 AM


Well thanks for your help Martin - of course I tested it - just a lot
of fields and factors going on.  I like to get clarification from the
helpful FM community sometimes.

Kind Regards
Jay
:-)
0
Reply Jennifer_Beecroft (79) 5/16/2012 11:11:48 AM

The reason why I was asking is because I'm trying to use an If
calculation function in calculation fields where result is text.  You
confirmed what I thought was true above, so I don't understand why it
is not working:

My calculation is the following for each respective field: Field1:
If(ABorC1="A";PartsUsed1)
 
Field2: If(ABorC2="A";PartsUsed2)
 
Field3: If(If(ABorC3="A";PartsUsed3) etc etc up to field 17

However at the moment even if one of fields with a pop up menu ABorC
is not equal to A but is actually equal to B or C the parts used field
is still the result whereas I'd actually want it to be blank if the
value is B or C and only show the value if it applies to A and A is
true for the relevant ABorC field.

Can anyone think why this is?  I'm stumped so far!

Many Thanks
Jay
0
Reply Jennifer_Beecroft (79) 5/21/2012 6:18:49 PM

On Mon, 21 May 2012 11:18:49 -0700 (PDT), JayBee wrote:
>  The reason why I was asking is because I'm trying to use an If
>  calculation function in calculation fields where result is text.  You
>  confirmed what I thought was true above, so I don't understand why it
>  is not working:
> 
>  My calculation is the following for each respective field: Field1:
>  If(ABorC1="A";PartsUsed1)
>   
>  Field2: If(ABorC2="A";PartsUsed2)
>   
>  Field3: If(If(ABorC3="A";PartsUsed3) etc etc up to field 17
> 
>  However at the moment even if one of fields with a pop up menu ABorC
>  is not equal to A but is actually equal to B or C the parts used field
>  is still the result whereas I'd actually want it to be blank if the
>  value is B or C and only show the value if it applies to A and A is
>  true for the relevant ABorC field.
> 
>  Can anyone think why this is?  I'm stumped so far!

A) does it rely on fields which may be empty? Did you tick the options
to compute on empty fields?

B) is it a calculation field with result text or an autoenter on a
simple text field? If text field, mark the option to replace field
contents with new results

C) is the one of the fields a related data? This may cause trouble
especially if the source is within another file. Data should be within
the same file, within another table.

D) is the data from a relation? Then calculation may be blocked until
the record is left.

E) is one of the fields for the calculation still active? Calculation
will happen only if the field was left.

Just some ideas...
Martin
0
Reply t-usenet (136) 5/21/2012 6:27:54 PM

"Martin?rautmann" <t-usenet@gmx.net> schreef in bericht 
news:slrnjrl29a.2v8.t-usenet@ID-685.user.individual.de...
> On Mon, 21 May 2012 11:18:49 -0700 (PDT), JayBee wrote:
>>  The reason why I was asking is because I'm trying to use an If
>>  calculation function in calculation fields where result is text.  You
>>  confirmed what I thought was true above, so I don't understand why it
>>  is not working:
>>
>>  My calculation is the following for each respective field: Field1:
>>  If(ABorC1="A";PartsUsed1)
>>
>>  Field2: If(ABorC2="A";PartsUsed2)
>>
>>  Field3: If(If(ABorC3="A";PartsUsed3) etc etc up to field 17
>>
>>  However at the moment even if one of fields with a pop up menu ABorC
>>  is not equal to A but is actually equal to B or C the parts used field
>>  is still the result whereas I'd actually want it to be blank if the
>>  value is B or C and only show the value if it applies to A and A is
>>  true for the relevant ABorC field.
>>
>>  Can anyone think why this is?  I'm stumped so far!
>
> A) does it rely on fields which may be empty? Did you tick the options
> to compute on empty fields?
>
> B) is it a calculation field with result text or an autoenter on a
> simple text field? If text field, mark the option to replace field
> contents with new results
>
> C) is the one of the fields a related data? This may cause trouble
> especially if the source is within another file. Data should be within
> the same file, within another table.
>
> D) is the data from a relation? Then calculation may be blocked until
> the record is left.
>
> E) is one of the fields for the calculation still active? Calculation
> will happen only if the field was left.
>
> Just some ideas...
> Martin

Hi Jennifer,

Not quite an answer, but you also might think about restructuring your data.
It seems like are are repeating the same action 17 times for almost the same 
information.
And what if within an month or so an other 4 ABorC fields are needed?
Are you then going to make 4 more fields, and 4 more calc fields?
it seems to me that PartsUsed should be a table of its own.
Then the main table should be joined many-to-may to the PartsUsed table.
It is then not only possible to create an occurrence based on ABorC, but the 
contents of your fields are directly visible through a portal.
And you can add as many as needed without creating all these fields.

It will need some more work then explained here, I just wanted to make the 
point that repetitive work should not be done by the human, but by the 
database.

Keep well, Ursus 

0
Reply Ursus.kirk8751 (6) 5/21/2012 8:39:43 PM

In article
<36681ad8-c916-46d1-b352-e6f7207ff850@b26g2000vbt.googlegroups.com>,
JayBee <Jennifer_Beecroft@hotmail.com> wrote:

> The reason why I was asking is because I'm trying to use an If
> calculation function in calculation fields where result is text.  You
> confirmed what I thought was true above, so I don't understand why it
> is not working:
> 
> My calculation is the following for each respective field: Field1:
> If(ABorC1="A";PartsUsed1)
>  
> Field2: If(ABorC2="A";PartsUsed2)
>  
> Field3: If(If(ABorC3="A";PartsUsed3) etc etc up to field 17
> 
> However at the moment even if one of fields with a pop up menu ABorC
> is not equal to A but is actually equal to B or C the parts used field
> is still the result whereas I'd actually want it to be blank if the
> value is B or C and only show the value if it applies to A and A is
> true for the relevant ABorC field.
> 
> Can anyone think why this is?  I'm stumped so far!
> 
> Many Thanks
> Jay

Change the If statement to enforece an empty result when the test fails.
e.g.
     If (ABorC1="A"; PartsUsed1; "")

Also make sure the Calculation Field is set to NOT be stored and TO
calculate when the source fields are empty.

Helpful Harry  :o)
0
Reply HelpfulHarry2 (409) 5/21/2012 9:05:03 PM

Thanks for everybody suggestions.  As i was running back through my
work and looking at suggestions - I realised it was blatnatly my
fault.  I made a stupid mistake.  Copying and pasting the calculation
from one field to another is fine......As long as you remember to
change the important parts in the copied text... :-/.  Sorry , a
simple mistake on my part that was easily fixed once I realised what
it was ... BUT a little bit embarassing.

Because I'd only been changing the second field name PartsUsed2,
PartsUsed2 etc in the respective calculation fields, but I'd forgotten
to change the ABorC field names to 2, 3 etc, it was looking in ABorC1
field for all of the results.....

Really sorry about this.

Jay

0
Reply Jennifer_Beecroft (79) 6/10/2012 9:53:34 AM

7 Replies
93 Views

(page loaded in 0.327 seconds)

Similiar Articles:













7/13/2012 12:34:06 PM


Reply: