# Calculation using If for two cases

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

## Recommended Posts

Hi all

I am trying to get a calculation field called GST working to fuction like an if, elseif statement.

THere are two situations where this calulation needs to be done.

GST=

If Classes::type="Movement and Music" then cost*.07

or GST=

If Classes::type="birthday" then cost+14

Here is what I had for the first part.

GST=

If ( Classes::type="Movement and Music" ; cost*.07 )

THis works for the first instance.

If ( Classes::type="birthday" ; cost+ 14 )

Filmaker complains that there is an operator missing.

I tried adding an or in between but that seemed to give a value of "1" when either case occurs.

Any Ideas about what I might be doing wrong?

##### Share on other sites

I prefer the Case, it is easier to read and to writht

Off of the top of my head, try:

Case (Type="Movement and Music"; cost*.07; Type="Birthday"; cost +14)

or maybe

Case (Type="Movement and Music"; cost*.07; Type="Birthday"; cost +14; cost)

In case you want a cost when it doesn't meet the critera.

HTH

Lee

##### Share on other sites

Lee

Thanks for your reply. What a wonderful thing this forum i!! The "Case" function works like a charm much better than the if statement.

Now my problem is the result of the calculation field needs to rounded to two decimal points.

Here is what I have

Case (Classes::type="Movement and Music" ; cost*.07; Classes::type="instrument"; cost*.07; Classes::type="birthday" ; cost*.07; Classes::type="CD"; cost*.07)

I figure it has something to do with the Round function but I can't figure out how to use it.

##### Share on other sites

You got it:

Enclose the whole thing in the Round.

Round ( Case (Classes::type="Movement and Music" ; cost*.07; Classes::type="instrument"; cost*.07; Classes::type="birthday" ; cost*.07; Classes::type="CD"; cost*.07) ; 2)

HTH

Lee

##### Share on other sites

Lee

Thanks very much that works perfectly.

##### Share on other sites

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

## Create an account

Register a new account