Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7797 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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

Posted

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.

  • Newbies
Posted

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 ...?

Posted

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!

Posted

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

Posted

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

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

Posted

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

This topic is 7797 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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