3 Replies Latest reply on Aug 7, 2014 8:36 AM by philmodjunk

    Need help with "If" statement



      Need help with "If" statement


           I am new and trying to figure out how to get a new field to calculate from an "If this, then" statement.   I need a field that calculates all of the acres for just my soybean records.  For example, If Crop=Soybeans, add all the Acres.

           Thanks in advance.

        • 1. Re: Need help with "If" statement

               And how is that table set up?

               If you have one record for each field (or crop?) with an acres field. You can create a calculation field like this:

               If ( Crop = "Soybeans" ; acres )

               And then define a summary field to compute the "total of" the above calculation field.

               But this requires creating one such calculation field for every crop that you have in your table. There are easier ways to get total acreage for each crop. One such method is a summary report. Here's a tutorial on summary reports: Creating Filemaker Pro summary reports--Tutorial

          • 2. Re: Need help with "If" statement

                 Phil, the table is set up in a summary report format.  It is separated by farmer, and then sorted by tract # and then field #.  Each farmer has a grand total of acres before the next farmer's records.  At the bottom of the report I need to show a grand total of soybeans, corn, rice, etc.

            • 3. Re: Need help with "If" statement

                   Notice the time (yours and mine) that you would have saved had you provided that info.

                   The calculation field approach is one way to get those totals though it is not flexible and requires a pair of fields for every crop. But it IS simple to set up so you may want to use that option until you can figure out one of the more sophisticated options that aren't so inflexible.

                   If you are using FileMaker 12 or newer, see this thread on a "summary recap" use of the ExecuteSQL function:

              FMP 12 Tip: Summary Recaps (Portal Subtotals)

                   If you don't wish to use SQL or are using an older version that does not have this function, it is also possible to set up a table where you have one record for each type of crop that then links to your table by that crop type field so that each record in this added field can use Sum () to compute a total acreage for that crop. You then put a portal at the bottom of your report to this newly added table in order to show the total acreage for each crop. It's more flexible than using the calculation fields as you can add or remove crops from your system by adding/removing records in this table--a data entry task that does not require your skills as a developer to do.