Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

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

counts and summaries

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

    counts and summaries

    As it is in life, the closer you get to the window at the end of the hall, the more you can see of the world of Alpha 5 around you.....

    I think that I am correct, (quietly hoping I am not), in the following premise:

    tablecount(), tablesum(), dbcount() and dbsum() ALWAYS and ONLY glean data from the ENTIRE TABLE. Separating some of the data into a query subset, and then using these functions would result in the same data as obtained from the entire table.

    Only Total() and Count() can select data from subsets of the entire table...

    Which would mean that the first group of functions would be used ONLY for a YTD report or summary and the second group would HAVE TO BE USED for summarizing weekly, monthly, quarterly, etc -- or any other subset of the data in the table.

    This 'gem of information' is what I am able to understand from the chm..

    I'm sure that many of you are aware of how painfully slow Total() and Count() can be for a report containing a large number of variables from a large table.

    Thanx for any comments
    D

    #2
    Re: counts and summaries

    Dik,
    Not sure what you mean by this:

    "tablecount(), tablesum(), dbcount() and dbsum() ALWAYS and ONLY glean data from the ENTIRE TABLE"

    These functions all take a filter (or an index with a key) and therefore only work on records that satisfy the filter. If you have appropriate indexes, they should work quickly enough. No?

    - Peter

    Comment


      #3
      Re: counts and summaries

      I look at it a different way.

      tablecount(), tablesum(), dbcount() and dbsum() ALWAYS and ONLY glean data from the table specified according to the filter you specify. No outside influences are considered.

      Total() and Count() can select data from subsets of the entire table, only in the current context...


      If that subset is actually the whole table you get the grand total. If that subset is limited by the report's filter, you get a limited value return. You can't tell total() what records to consider.

      I often use both total() and tablesum() in a report. Suppose you are reporting on some data covering a month and limit the report to a month's records. Total() will give you the total for the month. Tablesum() can give you the total for the table, total for a quarter, total for a year. total for a salesperson, etc.
      There can be only one.

      Comment


        #4
        Re: counts and summaries

        Even when I think I am very specific, apparently I am not.

        The 'report' that is being generated is actually a 'form'. Client prefers a more visual representation than I (at least at this time) am able to generate with the report writer.

        Sooooo
        Form is sectioned into coherent, connected variables and then displayed. The form includes totals that are obtained from variables or calculated fields that are present on the form or obtained from data in the tables (both parent and child tables are used for data collection)..........

        Since I have solved my problems with the data presentation, I do not wish to get into zipping an example. I was just trying to get a better understanding of the named functions.

        However, it seems that I have been unable to properly filter the first group of functions in order to meet my needs, so when that occurred, I used the second group of functions. In some cases that required adding fields to the table, but resulted in an acceptable result.

        What I read from your responses is that I need more education in describing and creating filters. Most of my problems occurred when I needed to filter by more than one attribute AND only total() and count() allow that -- as far as I can determine. EG the report needs to display: the number of transactions that contain a group (some may contain more than one group) **** NOTE the word group just means a type of transaction **** then it must also display (for each group) the sales units, the sales dollars (both taxable and non-taxable and the sales tax collected)

        In short summary: some data from only the parent record; some data from only the child records, some data from the child records based on the parent record.

        I'm sure that there are those out there who are smiling now because they've been here. Also sure that I may smile later -- just not right now....
        D

        Comment


          #5
          Re: counts and summaries

          Total() and count() accept no filtering. Outside of a report where you can create groups, the only way to modify these functions is to use the group parameter specifying

          GRAND (all records)
          The name of the current table
          The name of a table in the current set

          If you have some time, take a look at my attachment in this thread. It illustrates some usages of tablesum(), etc which I do not believe are possible with total(), etc.

          Additionally, if you are not aware, total() and its cousins are limited outside of the report writer context although they do have some capabilities in forms, letters, etc. From the webhelp for total()........

          Limitations

          This function is a report writer function, not intended for table level field rules or other expressions. While the function may perform in some areas outside of the report writer, its use there is not supported.
          There can be only one.

          Comment


            #6
            Re: counts and summaries

            Ok - Stan, thanx for the example...
            Not sure I understand just yet, but I'm working on it.

            To be as specific as I can -- In a table containing several numeric fields like charge, non-taxable, taxable, tax --
            I need to count the # of records that have a field (like non-taxable) with a value greater than 0. I really need to use the table....() and db....() functions because they are much quicker and I need to get these counts for 13 different categories, each with 4 to 5 fields to summarize.
            I am not able to determine 'the filter' to do that job. Everything I try gives me some error - most times it's 'too many parameters'.
            In an earlier version, I used total() and it did the job but took 5 or 6+ minutes to generate the data on the form.

            I may have more 'hangups' later, but this is the 'squeaky wheel' at the moment. If you can point me in the right direction, it would be appreciated.

            D

            Comment


              #7
              Re: counts and summaries

              Just spent a bit of time with my buddy (the chm)....
              Anyone care to tell me why the following codes do not give the same result?

              Code:
              filter="company = "+quote(thename)
              ?filter
              = company = "Dick Coleman"
              Code:
              xx="company = "+quote(thename)
              ?xx=.F.
              AND why is this filter expression for an index "month(inv_date)=1" is accepted but this filter expression for a field "tblfieldname>0" generates too many parameters as an error

              And please don't start the explanation with 'Everyone knows........"

              thanx
              D
              Last edited by dik_coleman; 01-10-2008, 03:03 AM. Reason: added an example

              Comment


                #8
                Re: counts and summaries

                Code:
                dim thename as C
                thename = "Dick Coleman"
                dim xx as C
                xx = "Company = " + quote(thename)
                ?xx
                = Company = "Dick Coleman"
                
                filter = "Company = " + quote(thename)
                ?filter
                = Company = "Dick Coleman"
                D, the code you present should return the same result assuming the antecedent conditions were the same. They were different. Can't tell you what it might be because you haven't shown us the entire script or given us the context in which the scripts were running.

                D, we'll be able to see the stumbling block and will more likely be able to offer specific suggestions if you furnish us a small data set to work with. May I suggest that we try to walk before running? How about preparing an example that handles one category and only a couple of fields to summarize? Explain what you want the form to show, and then zip the sample for posting here.
                Last edited by Tom Cone Jr; 01-10-2008, 07:27 AM.

                Comment


                  #9
                  Re: counts and summaries

                  D, in the absence of a data set from you, maybe a couple of easy examples from AlphaSports will help.

                  Open the Invoice form in design mode, create two new calculated values as follows:
                  Code:
                  [COLOR="Red"]pr[/COLOR]_[COLOR="Red"]gt[/COLOR]_20 = tablecount("invoice_items","Invoice_Items->Invoice_Number = "+quote(Invoice_Number)+" .and. Invoice_Items->Price > 20.00")
                  
                  [COLOR="Red"]q[/COLOR]_[COLOR="Red"]lt[/COLOR]_2 = tablecount("invoice_items","Invoice_items->Invoice_number = "+quote(Invoice_number)+" .and. Invoice_items->Invoice_Items->Quantity < 2")
                  Then drop them on the form. Expand the format property of the display field objects to 4 characters, since by default this will be set to only 1 char wide.

                  The first calc value (pr_gt_20) will display the number of items in the current invoice where the Price is Greater Than 20.

                  The second calc value (q_lt_2) will display the number of items in the current invoice where the Quantity is less than 2.

                  Hope this helps. -- tom
                  Last edited by Tom Cone Jr; 01-10-2008, 08:47 AM.

                  Comment


                    #10
                    Re: counts and summaries

                    Just got a back.... will look at your example and edit this to reply
                    D

                    OK Tom -- it works, but that is not the situation that needs to be resolved.
                    In Alpha Sports, I would need to count all the invoices that contain "Alpha Sports Cap", I also need (for those invoices only) the total number of units sold and the total sales $.

                    In my app, I have 13 categories some are taxed, some are not, some have both tax and no tax field values. The only reference to the child 'category' in the parent record is a flag - used for counting the parent. For each category, I need the total number of parent records that have children with 'that category' in the child record..... then the total units and $ taxable, non-taxable and the am't of the sales tax collected. It gets crazy trying to create a filter that can be used to reference both the parent and the child.

                    by the way, check your q_lt_2 formula, you have dislexic fingers
                    Last edited by dik_coleman; 01-14-2008, 12:18 AM. Reason: complete answer

                    Comment


                      #11
                      Re: counts and summaries

                      D, welcome back.

                      It's clear I didn't understand what you're struggling with. Even now it's still very cloudy. "Categories" is not a term that is used in Alpha terminology so I was guessing...

                      Using AlphaSports model, if you included a customer identifier in each invoice_items table record you'd be able to easily count specific items and total sales $ for each customer. You can generate count and totals for specific items (tablewide, i.e. for all customers) already. The tradeoff is a bit of redundancy in each items table record.

                      An alternative would be to use an inverted set and a custom script that steps through the records accumulating various counts and totals as it goes.

                      -- tom

                      Comment

                      Working...
                      X