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.

Displaying a total from a related Field

Featured Replies

I have a table with a course total (£600, or £1000) in each record.

I am looking at this table via a relationship, I what I need to do is count how many £600's there are and how many £1000's there are (not total, but display number so if there were 6 values of £600 in the related records it would display 6)

Thanks!

13 minutes ago, Chrism said:

I have a table with a course total (£600, or £1000) in each record.

I am looking at this table via a relationship

If you want to run a query on the whole courses table then your starting context doesn't matter, except that it may complicate things a bit in displaying the result.

There are a couple of different ways to do this, one way is to run an executeSQL() query on the courses table that does a COUNT(*) and GROUP BY on the course total field.  The result of this will be a return delimited chunk of text.  You can show that in a global text field or go the extra mile and use a Virtual Table to display the result.

If you are not familiar with SQL then this is a nice exercise.

You can also display the results in a web viewer using a nice data visualization library.

You can also just spawn a new window and loop through your course records (actually visiting each one or with the GetNthRecor() function) and keep a running tally per course total.

Many options available to you.  If you have tried one or two but got stuck, let us know what you have done already and we can see if we can get you unstuck.

 

  • Author

Don't worry sorted!

In the interest of contributing to the community, maybe post how you ended up doing it so that the next person can learn from it?

  • Author

Yep no problem, calculation field as below

 

ValueCount ( FilterValues ( List ( table::field ) ;  "600"  ) )

  • Author

However I'd also like to count of possible if value is not £600.

Can I adjust this calculation to be a 'Not' in someway?

 

Thanks

Look for a custom function by the name "antiFilterValues" or roll your own with the While() function to iterate over the list.

But in general: using fields for this kind of thing is perhaps not the way to go.  You don't want to be adding a field every time you have a course with a different price point.

 

1 hour ago, Chrism said:

However I'd also like to count of possible if value is not £600.

Can I adjust this calculation to be a 'Not' in someway?

How about:

Count ( table::field ) - ValueCount ( FilterValues ( List ( table::field ) ; "600" ) )

Note that this counts all non-empty values that are not "600". If you want to include empty values in the count, start by counting a field that cannot be empty - e.g. the match field for the relationship.

 

Edited by comment

  • Author

Perfect thank you

Create an account or sign in to comment

Important Information

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

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.