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.

Count Field Occurance

Featured Replies

Have a passenger list and next to their name it has 'adult', 'child' or 'infant' in a drop down list.

At the bottom I wish to summarise the booking schedule so the person reading the report can see how many times 'adult' was selected for example.

 

The following is in a portal:

 

Age Bracket, First Name, Last Name, etc etc

(Adult, Child, Infant), (First Name), (Last Name) etc etc

 

At the bottom of the screen I wish to have:

 

Adults: x

Children: x

Infants: x

 

Thank you in advance. I love using this forum to learn!

Try:

Let([
L = List ( YourTable::Age Bracket ) ;
A = ValueCount ( FilterValues ( L ; "Adult" ) ) ;
C = ValueCount ( FilterValues ( L ; "Child" ) ) ;
I = ValueCount ( FilterValues ( L ; "Infant" ) )
];
List (
If ( A ; "Adults: " & A ) ;
If ( C ; "Children: " & C ) ;
If ( I ; "Infants: " & I )
)
)

If that doesn't work, then the old-fashioned way will. :)

Create three new Calculation fields in the portal's Table:

IsAdult = If (Age Bracket = "Adult"; 1; 0)

IsChild = If (Age Bracket = "Child"; 1; 0)

IsInfant = If (Age Bracket = "Infant"; 1; 0)

Then in the main Table you can create Calculation / Summary fields to total those three fields:

SumAdult = Sum (Relationship::IsAdult)

SumChild = Sum (Relationship::IsChild)

SumInfant = Sum (Relationship::IsInfant)

Ugh... that's 6 new fields to count values of one field...

 

That's the kind of stuff that makes a database slow and difficult to maintain.  Raybaudi's approach is much better.  And there is also ExecuteSQL, a looping script,... many different ways that will not burden the schema with unstored calculations and summary fields.

I never said it was elegant nor even the "best" solution. It's simply one possible solution that works in any version of FileMaker and is easy to see how it works.

I never said it was elegant nor even the "best" solution.

 

Then what is the problem? The assessment of pros and cons of any proposed solution is a legitimate part of the discussion.

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.