Moon Rabbit Posted April 9, 2012 Posted April 9, 2012 I have a field (concentration) that is a calculation based on three other fields: 1. Total volume (i.e., 25 ml) 2. Volume of chemical added (i.e., 0.00035 g) 3. Purity of chemical added (i.e., 99.8%) The field calculates a ppm value based on these three numbers, no problems there. The issue I have is that I need to be able to calculate the number of significant figures in each of the three source fields, then display the result with the proper number of significant figures. [0.00135 g (3 SF) x .99 (2 SF) ]/25.0 ml (3 SF) = 53.46 ppm, but it has to appear as 53 ppm because the result has to equal the least number of significant figures in any the source fields. [0.00135 x .998]/25.0 = 53.9 ppm [0.001350 x .9980]/25.00 = 53.89 ppm So the field display has to change based on the calculation. I have the sigfigs custom function, but I'm trying to figure out how to apply it. Do I just need to format the field as "general" and set the significant figures via a script using the custom function, or is there a way to script the field number display formatting?
LaRetta Posted April 9, 2012 Posted April 9, 2012 Hello Moon Rabbit! I am not clear on your need but since this hasn't been answered, I will give it a go. "So the field display has to change based upon the calculation" If you are saying that, in one calculation result, the field should display 53.9 ppm and in another it should display 53.89 ppm, are you saying that the rounding would be what changed depending upon the results of your custom function? If so then there are two approaches (create another calculation to display the result or use conditional formatting and merge variable. What you do NOT want to do is use script for it but rather, you want it to be automatic. [0.00135 g (3 SF) x .99 (2 SF) ]/25.0 ml (3 SF) = 53.46 ppm, but it has to appear as 53 ppm because the result has to equal the least number of significant figures in any the source fields. What are the 'significant figures' in this string? Please translate this into human speak. It would probably help if you provided a sample file with your custom function and the concatenated calculation with a few records.
comment Posted April 11, 2012 Posted April 11, 2012 When it comes to numerical operations, a field containing the entry "25" is practically indistinguishable from another containing "25.00". Filemaker provides the option of displaying the entries "as entered" - but any numerical operation will treat them the same way. The other thing is that a calculation resulting in a Number will never have trailing zeros. For this, you must set the field to return a Text result and do your own formatting within the calculation formula.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now