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

how can I count occurrence number of each item in value lists

Featured Replies

I'm using FileMakerPro Adv 13

 

Considering There are records like these below

 

1 Orange

2 Apple

3 Strawberry

4 Apple

5 Lemon

6 Apple

7 Orange

8 Melon

 

I have a value lists called "TypeOfFruits"

then If I execute this function

 

Substitute(Substitute ( ValueListItems ( Get ( FileName ); "TypeOfFruits"); "¶"; "n") ;" ";"")

 

I get this output

 

OrangenApplenStrawberrynLemonnMelon

 

It is shown on a page just like this

 

Orange

Apple

Strawberry

Lemon

Melon

 

If I want to count all of them and want an output like this, how can I change my function above?

(sorted by the number of count)

 

3...Apple

2...Orange

1...Strawberry

1...Lemon

1...Melon

you can always use this function in a script step setting a field. - just change the items in bold your field names and table name.

 

ExecuteSQL ( 
"SELECT typeOfFruits, COUNT(*) FROM sample GROUP BY typeOfFruits ORDER BY 2 DESC"
 ; "" ; "")

or if you want it more in line like you example 

 

3...apple

2...orange

1...strawberry

1...lemon

1...melon

 

ExecuteSQL ( 

"SELECT COUNT(*), typeOfFruits FROM sample GROUP BY typeOfFruits ORDER BY 1 DESC"
 ; "..." ; "")
  • Author

 

Thanks for introducing the custom function!!!

 

This is what I wanted!!! Thanks so much!!!!

 

you can always use this function in a script step setting a field. - just change the items in bold your field names and table name.

 

ExecuteSQL ( 
"SELECT typeOfFruits, COUNT(*) FROM sample GROUP BY typeOfFruits ORDER BY 2 DESC"
 ; "" ; "")

or if you want it more in line like you example 

 

3...apple

2...orange

1...strawberry

1...lemon

1...melon

 

ExecuteSQL ( 

"SELECT COUNT(*), typeOfFruits FROM sample GROUP BY typeOfFruits ORDER BY 1 DESC"
 ; "..." ; "")

 

This SQL also looks useful!!

 

Thanks for the advanced technique!!

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.