Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Getting a Quick Sum of a Column

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting a Quick Sum of a Column

    Greetings,

    Is there a way, in A5V7, to get a sum of a column, without creating a report or writing Xbasic to read every record in the file?

    I have a transaction file that has several hundred rows and I have a value of those transactions based on a monetary filed in the data.

    I promise to wash my mouth afterwards, in MS-Access you can do a Quick Query and sum the column and have a total in seconds with designing a report per-sae or writing code... can you do the equivalent in A5?

    Regards,
    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  • #2
    Re: Getting a Quick Sum of a Column

    Keith,

    Not sure if this will suffice but on the toolbar next to the excel button is a yellow button for field statistics. Place cursor in the field you are interested in and press the button. The item second from the bottom is total.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

    Comment


    • #3
      Re: Getting a Quick Sum of a Column

      Originally posted by Tim Kiebert View Post
      Keith,

      Not sure if this will suffice but on the toolbar next to the excel button is a yellow button for field statistics. Place cursor in the field you are interested in and press the button. The item second from the bottom is total.
      Hi Tim,

      THANK-YOU !!

      How in the world that I missed that is unbelievable, the Total and Average are just what I needed! Now, I need to look into what the Expression Tab will allow, this WILL make my life easier !!

      Regards,
      Keith
      Keith Weatherhead
      Discus Data, Ltd
      kweatherhead@gmail.com

      Comment


      • #4
        Re: Getting a Quick Sum of a Column

        Originally posted by KeithW View Post
        Hi Tim,

        THANK-YOU !!

        How in the world that I missed that is unbelievable, the Total and Average are just what I needed! Now, I need to look into what the Expression Tab will allow, this WILL make my life easier !!

        Regards,
        Keith
        Field statistics.
        There can be only one.

        Comment


        • #5
          Re: Getting a Quick Sum of a Column

          Keith, Happy to help. After a bit of a play I found that the result is based on the active record set. So you can filter the records your favourite way and the resulting records will be used in the statistics. This applies to embeded browses as well. Check out this page in the help on the related function
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


          • #6
            Re: Getting a Quick Sum of a Column

            Wonder what that related function might be... Would like to be able to recreate the statistics button on an xdialog browse. But just copying the code from the toolbar doesn't do it - returns an argument incorrect data type error on line 43 using either addin.run("field_statistics") or a5_field_statistics()
            Robin

            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

            Comment


            • #7
              Re: Getting a Quick Sum of a Column

              Here's a few ideas I've played with.

              Add this table to a workspace and look at the code in the browse.

              testgrptotal.zip
              Al Buchholz
              Bookwood Systems, LTD
              Weekly QReportBuilder Webinars Thursday 1 pm CST

              Occam's Razor - KISS
              Normalize till it hurts - De-normalize till it works.
              Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
              When we triage a problem it is much easier to read sample systems than to read a mind.

              Comment


              • #8
                Re: Getting a Quick Sum of a Column

                That's pretty cool, but that is a button event that is part of the browse. I just want a stat button to work like it does on the browse toolbar but as part of the xdialog. Alpha auto adds in the navigation buttons, save and refresh in the dlg code when it gives you the xml definition. So it seems a stat button ought be possible too.
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment


                • #9
                  Re: Getting a Quick Sum of a Column

                  Robin,

                  I just want a stat button to work like it does on the browse toolbar but as part of the xdialog.
                  You can add the buttons as like the Navigation Buttons and add the events with your code.

                  Comment


                  • #10
                    Re: Getting a Quick Sum of a Column

                    Hi John,
                    As I said in post in #6, I tried that but the code errs. I tried the code from both of the system form and browse toolbars.
                    Robin

                    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                    Comment


                    • #11
                      Re: Getting a Quick Sum of a Column

                      Originally posted by MoGrace View Post
                      That's pretty cool, but that is a button event that is part of the browse. I just want a stat button to work like it does on the browse toolbar but as part of the xdialog. Alpha auto adds in the navigation buttons, save and refresh in the dlg code when it gives you the xml definition. So it seems a stat button ought be possible too.
                      This wasn't meant to be the final answer, but some options to get to it.

                      Can you post what you are starting with and info on how you want to improve it?
                      Al Buchholz
                      Bookwood Systems, LTD
                      Weekly QReportBuilder Webinars Thursday 1 pm CST

                      Occam's Razor - KISS
                      Normalize till it hurts - De-normalize till it works.
                      Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                      When we triage a problem it is much easier to read sample systems than to read a mind.

                      Comment


                      • #12
                        Re: Getting a Quick Sum of a Column

                        I found another function that might do it COMPUTE_FIELD_STATISTICS - I will try that then let you know how it went.

                        Edit: In using the script recorder on the xd to see what the sort buttons returned, I get this instead of the pointer to the browse object in the script:

                        generatedbrowse.quick_sort()

                        Well the Wiki is wrong. This function above returns a dot variable and is thus a pointer. How do I get the pointer results from the IW into a list I can display in a msgbox()? I am thinking I need an array? Where is Stan when you need him? But I am now off this thread since I haven't found a way to get a total SIMPLY which is what the OP was about.

                        ...More Info from the IW using a numeric field - and it works with the current query:

                        Code:
                        brw1 = topparent.this
                        v = brw1.GetActiveObjParent().active_drilldown()
                        ?typeof(v)
                        = "C"
                        ?v
                        = ":ApptList:HH_CNT"
                        
                        stats = compute_field_statistics(v)
                        ?typeof(stats)
                        = "P"
                        
                        ?stats
                        = Average = 0.363802559414991
                        count = 547
                        First = 5
                        Last = 1
                        Maximum = 6
                        Minimum = 0
                        Standard = 0.921610634766173
                        Total = 199
                        Variance = 0.849366162114108
                        now with a regular browse open I can use
                        a5_field_statistics()
                        and it brings up the statistics dialog - from the IW. Notice there is not any arguments for this function or a pointer needed, so when the toolbar uses this function it gets the info it needs on its own just like the other toolbar buttons do. But of course not if the browse is embedded in an xdialog. I noticed the script recorder only showed results from some of the buttons Alpha added.
                        Last edited by MoGrace; 01-12-2018, 04:16 PM.
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment


                        • #13
                          Re: Getting a Quick Sum of a Column

                          I am getting a bit closer to creating a function:

                          Code:
                          'Note:  brw1 is the pointer I used in the xdialog for the xml browse definition so
                          'defining it here is just for testing purposes
                          
                          brw1 = topparent.this
                          objname = brw1.GetActiveObjParent().active_drilldown()
                          t = brw1.Table_Get()
                          tname = t.name_get()
                          fld = word(objname,-1,":")
                          fptr = a5_field_info(tname,fld)
                          stats = compute_field_statistics(fld)
                          x=properties_enum(stats,"R,O=p: v")
                          
                          msgbox("Field Stats",ut(fld)+" Statistics:"+crlf(2)+x,0)
                          If you open a standalone browse and set a query, you can copy this to the IW and run it. If a numeric field is selected then
                          stats.total will return the value.
                          Last edited by MoGrace; 01-12-2018, 04:15 PM.
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                          • #14
                            Re: Getting a Quick Sum of a Column

                            I have since added another embedded xml browse in my XD so I changed the statistics button to read the field stats from either one:

                            Code:
                            brw = topparent.this
                            objname = brw.GetActiveObjParent().active_drilldown()
                            t = brw.Table_Get()
                            tname = t.name_get()
                            fld = word(objname,-1,":")
                            fptr = a5_field_info(tname,fld)
                            stats = compute_field_statistics(fld)
                            x=properties_enum(stats,"R,O=p: v")
                            
                            msgbox("Field Stats",ut(fld)+" Statistics:"+crlf(2)+x,0)
                            Note that now 'topparent.this' returns whichever browse is active.
                            Robin

                            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                            Comment


                            • #15
                              Re: Getting a Quick Sum of a Column

                              Originally posted by MoGrace View Post
                              Wonder what that related function might be... Would like to be able to recreate the statistics button on an xdialog browse. But just copying the code from the toolbar doesn't do it - returns an argument incorrect data type error on line 43 using either addin.run("field_statistics") or a5_field_statistics()
                              Finally got an error message that reveals something - from the IW without setting the session I got:

                              a5_field_statistics()

                              ERROR: Script:field_statistics line:43
                              topparent.child_enum("r,e=this.field_get().fullname_get()"): Argument is incorrect data type

                              It seems that the valid pointer for 'topparent' is what that function expects to find.

                              Edit: And that valid pointer for an xml browse in an Xdialog is 'generatedbrowse.this'
                              so here is my event code for the Statistics button on my XD that actually works:

                              Code:
                              If a_dlg_button = "b_Stats" then 	
                              	if brw1.active() <> "" then	
                              		fld = brw1.active()
                              		brw = generatedbrowse.this
                              	else
                              		msgbox("","Please select a column",0)
                              		end
                              	end if		
                              	
                              	'get info for the msgbox		
                              	t = brw.Table_Get()
                              	tname = t.name_get()
                              	'get the fully qualified object name	
                              	objname = brw.GetActiveObjParent().active_drilldown()		
                              	stats = compute_field_statistics(objname)
                              	x=properties_enum(stats,"R,O=p: v")		
                              	delete stats
                              	msgbox("Field Stats",ut(tname)-"->"-ut(fld)+" Statistics:"+crlf(2)+x,0)
                              end if
                              I couldn't however, get a valid pointer to the 2nd browse in the XD, but didn't really need it anyway. It seems since both browses have an active object, but only the 1st one defined gets used.
                              Note that a numeric field gets a Total entry:
                              Stat_Btn.jpg
                              Last edited by MoGrace; 04-15-2018, 10:50 PM.
                              Robin

                              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                              Comment

                              Working...
                              X