Jump to content
Server Maintenance This Week. ×

Count Field Occurance


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

Recommended Posts

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!

Link to comment
Share on other sites

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 )
)
)
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 3621 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.