7 Replies Latest reply on Jan 12, 2012 12:36 PM by philmodjunk

    SUM Script Help



      SUM Script Help


      Hey Guys!

      Back again, with another question...

      The goal that I am atempting to acheive today is a sumation script that adds up all volumes that are being pulled through a portal.  I have a basic understanding of how the SUM script works, but am unsure about how to get this scrip working with a portal....

      here is what i have thus far...(not much)


      1) I have x2 fields that are titled Volume Sum and Volume

      2) i have a calculation that SUM(Volume) 

      3) This script correctly sums everything in the Volume field and spits it out in the Volume Sum field. 

      4) i then put the volume sum field into the first row of the portal so that it pulls through multiple records.

      5) It correctly displays the total volume sum per item in the portal...

      6) HOW DO I SUM THE PORTAL ROW and have it spit out a TOTAL SUM per portal field?


      Thank you all for your help!!

      THIS FORUM IS AWSOME!!!!!!  :D


        • 1. Re: SUM Script Help

          I think we're missing too many details to be able to help you until you tell us more.

          3)  This script.... Is this really a script? I think you have a calculation here. What do you mean by "everything in the volume field"? Is this a reapeating field? That's my best guess at this point, but would like to be sure.

          4) How do I sum the portal....

          Do you want a total of Volume Sum for all records shown in the portal? Is this a portal with a portal filter?

          • 2. Re: SUM Script Help

            Hey Phil!

            i applogize for the confusion, allow me to clarify...

            You are correct in the verbage, it is indeed a calculation, not a script. also, what i meant by "everything in the volume field" is that every record has a volume that needs to be tracked...this is not a repeataing field.

            And the most important question, i would like the TOTAL VOLUME SUM for all records shown in the portal, and this portal is not filtered. very simple and straight forward.


            thanks again for all your help!

            • 3. Re: SUM Script Help

              Then I'm afraid this part of your original post confuses me:

              2) i have a calculation that SUM(Volume) 

              3) This script calculation correctly sums everything in the Volume field and spits it out in the Volume Sum field.

              Sum ( Volume ) produces the same result as just referring to Volume.

              Sum requires a list of fields to sum. It can sum fields in the same record if you use this syntax:

              Sum (Field 1 ; field 2 ; field 3 )

              It can sum the value in Field for all records related to the current record of the table where this calculation is defined if you use this syntax:

              Sum ( RelatedTable::Field )

              Listing just one field as the parameter  such as Sum ( volume ) is the same as saying give me the sum of 5. And the sum of 5 is 5 of course.

              There are two ways that you can show the portal total:

              You can define a calculation field in the layout's table as Sum ( PortalTable::Volume ) and put this field beneath your portal.

              Or you can define a summary field in the portal's table that compute the total of Volume and put it on this layout below the portal. If you are only using this total for reporting/display purposes, the summary field makes a good option. If you are editing the volume field in this portal, the calculation field with the sum function will update more smoothly.

              Should you use a portal filter, then you'd need to use the summary field and place it inside a one row portal to the same table occurrence and with the same filter expression.

              • 4. Re: SUM Script Help

                Hey Phil,

                i guess i am a little confused about how to acheive my goal. it makes complete sense that SUM(volume) spits out 5 = 5.  the reason why i did this is to show in the portal that the volumes are pulling through properly per record.  i am confused about your verbage "summary field". do you mean, i need to create a field within the portal that has a calculation set to sum everything that is in the volume field?  if so, i atempted this already...i put the "volume sum" field into the portal with the calculation SUM (Volumes) which just spits out whatever is in the Volume field on the other layout (5=5).  How do i get filemaker to sum up every "volume sum" field within the portal and have it display its total in another field? could you possibly be a little more specific...


                thank you!

                • 5. Re: SUM Script Help

                  Open manage | database | fields and select the portal's table in the table drop down.

                  Add a new field and specify "summary" as the field type instead of calculation.

                  • 6. Re: SUM Script Help

                    Hey Phil,

                    Thank you so much! i didnt know it was that easy...one question though, would i need to change volume field into a numberical field for the "tototal of" function to work? i curently have the volume field set as text and the data has been migrated in the format of 3L = 3 liters.  a nusence if the porgram only requires numbers, but a minor one at that!


                    thanks again for all your help today!

                    • 7. Re: SUM Script Help

                      It should be of type number. You can't select it for your summary field to compute a total if it is of type text.