7 Replies Latest reply on May 25, 2017 11:33 AM by Philip_Jaffe

    Counting Rows

    bdembar

      Hello,

      I am trying to figure out how to count rows in a table.  I have a file that has several tables. On one titled "Lessons", there are many lessons, that I would like to count.  There may be up to 120.  I can not figure out how to count them. 

       

      Thanks,

      B

        • 1. Re: Counting Rows
          Philip_Jaffe

          You can use these functions:

           

          Get (FoundCount) {counts the number of records (rows) in your found set}

          Get (TotalRecordCount) {counts the total number of records (rows) in your table}

          • 2. Re: Counting Rows
            bdembar

            Thanks.  That works great.  Now I want to only count the rows pertaining to a specific ID.  Would you know how to do that?

            • 3. Re: Counting Rows
              Philip_Jaffe

              There are several ways to do that.  It depends on how your relationships are set up and from what context you are doing the counting.

               

              Can you say more about what IDs you are counting?  What table?  Are they foreign keys?  Primary keys?

              • 4. Re: Counting Rows
                StephenWonfor

                If you create a calculation in each table that is FoundSet = get(found count) you will find that, when in a portal it will act like {{RecordNumber}}.  If you query that from your master table FieldName = max(related table::FoundSet) you get the number of rows.  You can also use count function and point it at the foreign keys for the portal.

                • 5. Re: Counting Rows
                  bdembar

                  This is to keep track of students.  There are several tables with the shared id "STUDENT ID MATCHING FIELD".  In the Lessons table I have many students with ID's that have many lessons.  I want to count each lesson for each student so that I know what semester it is.  There are 14 lessons per semester or 112 lessons in 4 years.  Is there a way to count the rows for each id? 

                  • 6. Re: Counting Rows
                    StephenWonfor

                    The calculation(s) will reassess the count of related records as you move from one student record to another.

                     

                    Stephen

                     

                    ---

                     

                    “The problem with using C++ … is that there’s already a strong tendency in the language to require you to know everything before you can do anything.”  -


                    Larry Wall (developer of the Perl language)

                    • 7. Re: Counting Rows
                      Philip_Jaffe

                      You can use the Count ( ) function to count IDs across relationships.

                       

                      For example, from the Student table, you could count the lessonIDs in the Lesson table to see how many lessons for the current student if you have a relationship defined as Student::ID = Lesson::_fk_StudentID