
1. Re: Trouble With Calculations
philmodjunk Sep 3, 2013 9:33 AM (in response to CeciliaBaldwin)I can't see enough detail in how you've set up your tables and relationships to offer much help. ON the one hand you say "all my fields are in one table", but then you describe a portal and an average of values in a portalwhich means you have a relationship and possibly a portal filter involved here.
Div ( price per quantity ; units per ), BTW, is integer division. It returns the portion of the answer to the left of the decimal point and any fractional/decimal value is discarded.
Div ( 5 ; 2 ) = 2 It does not return 2.5. To get 2.5 you would use 5/2 instead of the Div function.

2. Re: Trouble With Calculations
CeciliaBaldwin Sep 3, 2013 10:32 AM (in response to CeciliaBaldwin)Yes to many to many relationships  I'm trying to set up a recipe database that links ingredients with vendors and recipes .. I have 3 TOs to and have been confirming that my ids and references are correct.
Regarding the division  below is a picture of the rudimentary file & portal. I'm trying to make the $ per unit = div ( $ per quantity ; units per) . And all that it does is add zero ... (The $1 was because I wrote that in). And thank you for pointing out that it is integer division ; is there any way to make it a preference to leave the decimal value?

3. Re: Trouble With Calculations
SteveMartino Sep 3, 2013 10:47 AM (in response to CeciliaBaldwin)So you basically want to make $ per unit divide the $ per quantity by the Units Per?
If so, simply change the "$ per unit" field in Manage Database>Fields to a calculation. Make the calculation under 'Specify Calculation' as flollows:
Click the '$ per quantity' field, click the '/' operator, click the 'Units Per field' (no quotes). Make sure calculation result is 'Number', and click the "Do not evaluate if all referenced fields are empty". Which looks like what you may have.
Then in layout mode, in the inspector>data tab, format>Currency (should already be 2 decimal places).

4. Re: Trouble With Calculations
CeciliaBaldwin Sep 3, 2013 10:58 AM (in response to CeciliaBaldwin)Thanks Steve. I did all of that but it still either puts 0.00 or ? ... I'm not sure what else to try and do.

5. Re: Trouble With Calculations
SteveMartino Sep 3, 2013 11:35 AM (in response to CeciliaBaldwin)Are 2 fields the calculation references both of type 'Number'? And in Specify Calculation, the result is selected as 'Number' ?
You sometimes get a ? if the field isnt wide enough but I don't expect that to be the problem.
Can you post a screenshot of your Specify Calculation box?

6. Re: Trouble With Calculations
philmodjunk Sep 3, 2013 12:28 PM (in response to CeciliaBaldwin)If you are dividing and get a ?, most likely reason is that you've divided by zero. I suggest posting the actual expression from the Specify calculation dialog so that we can see it. The details make a difference. A screen shot of this dialog would be best.
is there any way to make it a preference to leave the decimal value?
Seems like you didn't read my previous post completely as I posted an example which Steve Martino has now explained in more detail on how to get the correct decimal result.

7. Re: Trouble With Calculations
CeciliaBaldwin Sep 3, 2013 12:44 PM (in response to CeciliaBaldwin)Actually, the problem seemed to be that I had it set up as an 'auto enter calculation' instead of calculation and now it seems to be working perfectly! thank you both!