Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

count records grouped by field

Featured Replies

  • Newbies

Hi,

I want to count records grouped by the value of a field.

So the output should by something like

value1 12 records

value2 20 records

value3 1 record

...

How should I do this ?

Thanx for your help

Here it goes .... Lets say that you have three fields "Field1", "Field2", and "Field3".... If you want a count of how many records have the word "CALL" (or whatever the word or number may be)in "Field1". Here is what you need to do ... Create a calculation field called "calc_field1_call" with the following calcualtion

If ( Field1 = "call", 1, "")

That will put the number 1 in that firld of every record that tas the word call in field1 - Then create a summary field for the total of "calc_field1_call" and BINGO you have a your total number...

Sorry if this is kinda hard to read... I am really bad at explaining things.

  • Author
  • Newbies

Thanx for your reply, Andrew.

I guess that your solution wouldn't be very practical when

the field contains a lot of different values (like a table

with the total number of records > 10.000 and the number of

distinct values of field is in the order of 100 or so)

and/or the values of field are not known beforehand.

That is why I thought this would be better done by some kind of

script. Ony how to build such a script ...?

I had a similar problem . . .

You will need to track how many records you have for this to work. We'll call that variable g_num_Records. The fields with g_ at the beginning are globals and MUST be globals for this to work.

<! initializing variables>

count = 0

g_field_One_value_One_Count = 0

g_field_One_value_Two_Count = 0

g_field_One_value_Three_Count = 0

Loop

If (Field_One = value_One)

set Field (g_field_One_value_One_Count, g_field_One_value_One_Count + 1)

End If

If (Field_One = value_Two)

set Field (g_field_One_Value_Two_Count, g_field_One_Value_Two_Count + 1)

End If

If (Field_One = value_Three)

set Field (g_field_One_value_Three_Count, g_field_One_value_Three_Count + 1)

End If

count = count +1

goto Next Record

End Loop If (count = g_num_Records)

I then had a layout specifically to display the globals.

Hope this helps you out! It's long and laborous, but the only way I figured out to do what I needed!

You need:

1. a Summary field that is Count(yourField)

2. a layout with a Sub-summary part (sorted by yourField) and no Body part

3. put yourField and the Summary field on the Sub-summary

4. Sort by yourField

5 Preview or Print

Another option is to use a self-join relationship, yourField::yourField.

Then create a calc field Count(self::yourField).

Depending on what your requirements are, you can use Fitch's method or you can also accomplish this using a self relationship. Just create a relationship within the same file based on the value field. Then have a calculation of count(self::valuefield). The method you use is up to you.

HTH, Mike

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.