Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Im having a difficult time with a calculation on a field.

I have one field that can have 3 possible results based on another field. For example, lets say i have two fields, A and B.

B is going to need a calculation that goes something like:

If A = result1, set field B to whatever

If A = result2, set field B to whatever

If A = result3, set field B to whatever

Ive tried creating a calculation based on the Case() function but im not sure that is going to do what i need. Here is an example of my script:


Case (

TaxType = "No Tax";

ExportTax = "0.00000";



TaxType = "State Sales Tax"

ExportTax = CombinedSalesTax;



TaxType = "State Use Tax"

ExportTax = CombinedUseTax

)

This calculation sets the ExportTax field on all records to 0.00000

Is there such a function that will set the ExportTax field correctly based on the TaxType field?

Thanks

Posted

Even if i remove the first line and perform strictly text to text it still does not function properly:


Case (

TaxType = "State Sales Tax"

ExportTax = CombinedSalesTax;



TaxType = "State Use Tax"

ExportTax = CombinedUseTax

)

It leaves the exporttax field empty for those records whose taxtype is NoTax, all other records have 0.00000

Posted

Try:


Case (

TaxType = "No Tax";

"0.00000";



TaxType = "State Sales Tax" ;

CombinedSalesTax ;



TaxType = "State Use Tax" ; 

CombinedUseTax

)

Note: a calculation field returns the result of a calculation - it does not "set" a field.

Posted

here is the scenario of why i would need it to do so.

When it comes to sales tax, there are 2 types of tax for each zip code 1. State Sales Tax, 2. State Use Tax. There are also states we are not required to charge tax in.

I have a field in this database for tax type. There are 3 types to choose from: state sales, state use or no tax.

State sales and state use are calculated base on city, county and state taxes. So i have a field that calculates all of the state sales taxes and all of the state use taxes. Those fields are CombinedStateSales and CombinedState Use.

To bring it all together, i have a field called ExportTax. This field defines which tax rate we need to use for that particular zipcode.

So i need the exporttax field to be dependent on the taxtype field.

If taxtype = no tax, i need the exporttax field to be 0

If taxtype = State Sales Tax, i need the exporttax field to reflect the amount that is in the CombineSalesTax field

If taxtype = State Use tax, i need the exporttax field to reflect the amount that is in the CombinedUseTax field.

So far through trial and error i cannot come up with a script or calculation to get this working in this manner.

Posted

A calculation field should be quite sufficient for this - I see no need to set a field by script or another method.

I am not sure why the calculation isn't working for you. Make sure the exporttax field is defined as a Calculation field, NOT as a Text field with auto-entered calculated result.

Posted

A calculation field should be quite sufficient for this - I see no need to set a field by script or another method.

A calculation has the advantage of not requiring user intervention.

On the other hand tax rules can be quite complicated and change in unpredictable ways over time. It might be more difficult to create and maintain a complicated formula than a script. A script might allow a more modular and algorithmic approach, e.g. with subscripts and comments. I doubt that 'TurboTax' tries to calculate Income Tax based on one giant math formula.

Posted

tax rules can be quite complicated

Maybe so, but such concerns would apply to the State Sales Tax and State Use Tax fields, not to the ExportTax field.

In any case, I firmly believe that a solution should never depend on a script running successfully for having correct and up-to-date data - and script triggers have not changed anything in this aspect.

Posted

I firmly believe that a solution should never depend on a script running successfully for having correct and up-to-date data

So do I ... where were you, when this happened:

http://fmforums.com/forum/showpost.php?post/344766/

--sd

Posted

Ill try to play around with the calculation today to try and get this to work correctly.

Am i on track with attempting to use the Case() function or would you recommend another function??

Thanks for all of you help thus far.

Posted

Ill try to play around with the calculation today to try and get this to work correctly.

Am i on track with attempting to use the Case() function or would you recommend another function??

Thanks for all of you help thus far.

You are correct in using the case function but incorrect in your understanding of how it works and where the calculation is used. A calculation doesn't set anything; it only returns a result. You need to select your field in field definitions; set it to be a calc field; and use the calc as written by Comment.

This topic is 5537 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.