Total Record Count

How can I get the total # of records in a table and display it to the end user in the application builder. Do I need to build a formula or is this available another way?

You can get the record with the latest row id by adding a Created On field and using the row_id() function. The number of records is equal to the row id of the first record when sorting by Created On field in descending order. However, this will only work if you never remove a record from the table since row id’s are never reused.

Another approach is having a second table that has a Link to table field to each record of the table you want to count the items for. Next, you can use the count() function on that Link to table field. This only works if you are sure that each new record is added as a linked record.

How can I get a record count for just a particular view. Ideally I want to add this to the top of my application so it says something like “36 Employees Available” where the “36” is a count of the records in this view. Can this be done?

You can create a data source in your page that gets the count() field for your employees table and show this in an application.

Thanks for the quick reply. So, how would this look? I have a datasource in my application that returns all the rows and displays them based on a view in my table. This view has 25 matching records. Where and how to I apply to count() code? Do I need a formula field in the table. The filed I would like a total count on is name ‘Road Name’ & it is a text field. Thanks!

It is more complicated than just applying the count() function on a view.

  1. Create a new table. For example Record counts
  2. This table has a link to table field to the table where you want to count the records for. For example: an Employee table.
  3. You need to add all the records from that table to your linked field
  4. The Record counts table has a Count field that counts all the records from the linked table.
  5. The Record counts table has a text field that contains the name of the table it is counting the records for.

Now you can go to the application builder.

  1. Create a data source that returns all records from the Records counts table that contain the name of the table you want the amount of records from . This should return one record
  2. Select the Count field of that record.

But the downside of this approach is that every time you create or delete a record from your table, you must keep your Record counts table in sync.