Jump to content
Server Maintenance This Week. ×

If / Then


PC Infoman

This topic is 6211 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Try an auto-entry text field as calculated value with the 'Do not replace' unchecked.

price1 and price2

Case ( not qty; "Call" )

price3

Case ( not qty; "N/A" )

Link to comment
Share on other sites

I am sorry John. I am new to this filemaker stuff. Can you explain to me what exactly I need to do to make your suggestion happen?

I would have thought I needed to attach some kind of script to the price1, price2 and price3 fields to have it look at the quantity field and then act appropriately. Am I wrong?

My I should explain more clearly:

This is a catalog database. My fields are as follows

InStockRental - Taking a product that is in stock and renting it.

InStockSale - Taking a product that is in stock and selling it.

NewBuildRental - Making a new product and renting it.

NewBuildSale - Making a new product and selling it.

Quantity - How many that are in stock.

Clearance - Selling off old stock at a cheaper price.

The only editable fields are "Quantity" and "NewBuildRental".

When somebody puts a dollar value in "NewBuildRental", it automatically calculates the value of "InStockRental", "InStockSale", "NewBuildSale" and "Clearance".

What I would like is for the calculation for "NewBuildrental", "NewBuildSale" and "Clearance" to be usurped with the text of my choice if the "Quantity" is 0 or blank while still doing the calculation for "NewBuildSale". If the value of "Quanity" is anything other than 0 or blank, I would like it to calculate all fields normally.

Edited by Guest
Link to comment
Share on other sites

not GetAsBoolean ( Quantity )

gives true ( 1 ) when quantity is 0 or blank, so you can make a calculation with Case function.

for example:

Case(

not GetAsBoolean ( Quantity );"the text of your choise";

"the normal calc"

)

Link to comment
Share on other sites

not GetAsBoolean ( number ) = not number

not GetAsBoolean ( number ) = not number or IsEmpty ( number )

The [not] flag into the checkbox makes your assertion right, but only then, not always.

While boolean algebra has only two elements, 0 and 1, a given number field has 3 levels:

1) a value

2) a zero

3) an empty value

the not operator gives:

1) zero

2) one

3) empty

AFAIK:

not GetAsBoolean ( "" ) = 1

not "" = 1

1 = 1

AFAIK:

not GetAsBoolean ( "" ) = 1

not "" = "" ( for FileMaker calculation engine )

1 ≠ ""

Link to comment
Share on other sites

What's up with all this "AFAIK" business...

IJTIOAIWSES!

I just tested it out and it works so everyone shhh! :B

not "" = 1 for the FileMaker calculation engine.

not nothing = something... seems fairly logical reasoning to me. How booleans work:

0

Empty Value

= False or 0

Positive or Negative Number

= True or 1

Not reverses either False or True...

Edited by Guest
Link to comment
Share on other sites

not "" = "" ( for FileMaker calculation engine )

Hmm. But the same FileMaker calculation engine says not "" = "" is FALSE.

I believe you are confusing two separate issues. The VALUE of the expression not "" is always TRUE, never empty. In fact, if you put this expression into a calculation field, it will return TRUE.

However, in order to get the value of an expression, the expression must be evaluated. This is true for any expression, not just the one here. When the calculation engine is too lazy to evaluate a calculation field, the FIELD is empty - but that does not mean the VALUE of the formula in the field is "".

Filemaker confuses the issue even more, by returning TRUE to the question IsEmpty ( calcField ). But now we are discussing the economics of evaluation, not Boolean algebra.

By wrapping the field reference in GetAsBoolean( Numberfield ), you have merely forced the expression to evaluate. I don't know why it evaluates when Numberfield is empty (I would expect it not to), but it does. But you could have also forced it to evaluate in many other ways, for example by:

Lookup ( ; not Numberfield )

Would that be a good solution? IMHO, the recommended practice to get a calculation field to evaluate when all referenced fields are empty is to check the box at the bottom of the formula - instead of adding redundant operations.

Link to comment
Share on other sites

http://www.acronymfinder.com/af-query.asp?acronym=IJTIOAIWSES

gives NO match :B

BTW:

1) make a number field ( number )

2) make a calculation field with this calc:

not number

What do you see into the calc field when number is empty ?

Link to comment
Share on other sites

I don't know why it evaluates when Numberfield is empty (I would expect it not to), but it does.

Hi comment

it evaluates as expected :B

From Help On Line:

------------------------------

GetAsBoolean function

Format

GetAsBoolean(data)

Parameter

data - any text, number, date, time, timestamp or container expression, or a field containing text, a number, date, time, timestamp or container.

Data type returned

number

Description

[color:red]Returns 0 if data has a value of 0 or is empty, all other values return 1.

Link to comment
Share on other sites

What do you see into the calc field when number is empty ?

That's because it's not evaluating... When creating your calc field, down the bottom where it says "do not evaluate if all referenced fields are empty" - untick that.

To remove all doubt, try it in the data viewer.

Link to comment
Share on other sites

Ok

Now re-tick that box and change the calc to:

not GetAsBoolean ( number )

What do you see into the calc field when number is empty ?

BTW: go to read my first post... I didn't say that someone had given a wrong answer, I only say a way to solve the problem... and that calc works as expected w/o thinking for that box.

Link to comment
Share on other sites

What I would like is for the calculation for "NewBuildrental", "NewBuildSale" and "Clearance" to be usurped with the text of my choice if the "Quantity" is 0 or blank while still doing the calculation for "NewBuildSale".

Little confusing here. What do you mean by "still doing the calculation"? That might affect what I'm about to say.

You already have a working calculation. Take that calculation and wrap it in a Case statement.

Case(isEmpty(quantity) or Quantity = 0); "Text of Choice"; YourCalc).

Link to comment
Share on other sites

Well, like I said before, a calculation is automatically done to determine the value of "NewBuildSale", "InStockRental", "InstockSale" anfd "Clearance" when a numerical value is entered into "NewBuildRental".

When "Quantity" is set to "0" or it has no value in it at all, I want the values of "InStockRental". "InstockSale" and "Clearance" to be set to "Call". However, when "Quantity" is set to "1" or any number greater that "1", I want the original calculations to be done instead.

Edited by Guest
Link to comment
Share on other sites

  • 2 weeks later...

This topic is 6211 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.