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

Tablesum filter

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

    Tablesum filter

    I'm trying to calcuate the total charges for each family. The total will go into a calculated field in the "family" table called TotCharges. The values I need to add together are in the "lessons" table in a field called "balance" (It's not really a balance field, it's the charge for that one row).

    When I hard code the filter, such as this: TABLESUM("lessons","family_num='006411' ","balance"), the balance is calculated correctly for that family. When I try to use a variable (taking the family number value from a field in the family table called "familynumber2", I get only the "Invalid or incomplete expression" error message. Here's my attempt to use a variable instead of hard-coding the filter:

    TABLESUM("lessons","family_num= " ' + familynumber2 + ' " ","balance")

    The "family_num" and "familynumber2" fields are both character fields.

    I'd appreciate another set of eyes on this.

    Thank you,

    Rob

    #2
    Re: Tablesum filter

    Update: I had a mistake in the variable syntax (good thing Steve will have a session on syntax later today).

    ...but the tablesum total is 0 for every record, even when I use the "recalculate field rules" utility.

    Thanks,

    R

    Comment


      #3
      Re: Tablesum filter

      Hi Rob,
      I used to use the syntax you are using years ago, and was experiencing many difficulties consistently getting it correct and often making/missing mistakes.
      Code:
      TABLESUM("lessons","family_num= " ' + familynumber2 + ' " ","balance")
      It was then suggested to me from a wise member on this board to change my syntax for filters to syntax that doesn't have so many ' and " that by the natural human visual condition are hard to pick out and separate. So I switched to the syntax suggested and since then my life has been so much better!
      Code:
      TABLESUM("lessons","family_num="+quote(familynumber2),"balance")
      As it was moving from this:
      Code:
      dim t as p
      t=table.open("families")
      query.filter ="family_num="+quote(familynumber2)
      query.order = "balance"
      qry = tbl.query_create()
      msgbox(t.balance)
      qry.drop()
      t.close()
      To:
      Code:
      dim t as p
      t=table.open("families")
      xt=t.order("balance","family_num="+quote(familynumber2))
      msgbox(t.balance)
      t.close()
      Mike W
      __________________________
      "I rebel in at least small things to express to the world that I have not completely surrendered"

      Comment


        #4
        Re: Tablesum filter

        Where are you doing this - in a form or in a report?
        Robin

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

        Comment


          #5
          Re: Tablesum filter

          Robin,
          I believe he is trying to make a calculated field rule in his "Family" table that sums the values in the "balance" field in his table "lessons" for each family.
          Mike W
          __________________________
          "I rebel in at least small things to express to the world that I have not completely surrendered"

          Comment


            #6
            Re: Tablesum filter

            In a dbf table using a calculated field.

            Comment


              #7
              Re: Tablesum filter

              I've been doing summat similar in a council app I'm building.
              I took a different approach as I need a formal account of changes to expenditure. You cannot delete so must reverse an entry.
              I'm using the Post Operation to add amounts +ive and -ive to a specific item in a budget vs expenditure table.
              See our Hybrid Option here;
              https://hybridapps.example-software.com/


              Apologies to anyone I haven't managed to upset yet.
              You are held in a queue and I will get to you soon.

              Comment


                #8
                Re: Tablesum filter

                Thanks, Ted. I've narrowed the problem. I can't get the id value from the current row into the filter. When I hard code it, it works, correctly. When I use the current() by itself, it shows the correct value, but when I use it as part of a filter, it shows 0. Here's what I think should work:

                tablesum("lessons","family_num='current(familynumber2)'","balance")

                The result is 0.

                If I hard code the id (which is "familynumber2" in one table and "family_num" in the other (both character fields) I get the correct result.

                If I try only "current(familynumber2) it returns the correct value for familynumber2.

                I've also tried treating current(familynumber2) as a variable, using " ' +Current(familynumber2)+ ' ". No dice.

                Thank you,

                Rob

                Comment


                  #9
                  Re: Tablesum filter

                  testtot = tablesum("amt","Fam = Var->vFam","Fees")

                  This works.
                  Expl

                  I set up a Calculated Field to test the logic.
                  amt = the cumulative value in the Fam (Family) table
                  Fam is the identifier
                  Var->vFam is set "on Fetch in the Form.
                  Fees is the cumulative fees for the Fam.

                  It would be easier for you to create a Form which captures the PK you want to use when a record is selected,
                  Create a Calculated Field on a Form which uses the PK in both Tables
                  Structure the filter as shown above.
                  "Fam = Var->vFam"
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  Apologies to anyone I haven't managed to upset yet.
                  You are held in a queue and I will get to you soon.

                  Comment


                    #10
                    Re: Tablesum filter

                    Ted,

                    I appreciate your thoughts on this, but your answer confuses me. I thought the tablesum method required (the table, the filter, and the field to be totaled). I'm guessing that your descirption should have said that "amt" is the table?

                    In addition, I thought it would be possible for me to create an expression in the calculated field using field rules. Is that not correct?

                    Thank you,

                    Rob

                    Comment


                      #11
                      Re: Tablesum filter

                      Correct, amt is the table.
                      The issue you will have is that a calculated field in the table will need to be recalculated on a change in the other fees table.
                      It won't happen automatically.

                      Try creating a Calculated field on a Form which updates when a new record is selected.
                      Once you have this working you can use the logic in your Table field.
                      You really don't need a database field to hold the summation unless you really want to.
                      See our Hybrid Option here;
                      https://hybridapps.example-software.com/


                      Apologies to anyone I haven't managed to upset yet.
                      You are held in a queue and I will get to you soon.

                      Comment


                        #12
                        Re: Tablesum filter

                        Here is an example.
                        Pull it apart and see what it does.

                        Recalculating the Family Total Fees in the Family Table won't happen unless the record is edited. Put a [.] after the name to see what I mean.
                        The Calculated Field on the Form should always be up to date though.
                        Family Name in the Fees is picked from the Family table for consistency.
                        Attached Files
                        See our Hybrid Option here;
                        https://hybridapps.example-software.com/


                        Apologies to anyone I haven't managed to upset yet.
                        You are held in a queue and I will get to you soon.

                        Comment

                        Working...
                        X