You need to either use the GetSummary() function or the ExecuteSQL() function to gather subsummarized data programmatically.
Alternatively, if you have a table of category records that are related to your questions table, then you can count through the relationship using the Count() function.
If you need these values programmatically, you could ...
- sort your records by category, then use a script to loop through the existing categories and use GetSummary ( sCount ; category ). Store a list of the found categories and a list with the respective counts in two variables and use that to set your fields
- use ExecuteSQL to do the same
yet another alternative would be to create and relate a global field to your Category table. Populate this global field with Category1, etc. and then use Count(TableRelatedByGlobal::pk_Category) to capture the number of related records.