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

Alternative to PatternCount for summarising unique values for a chart?

Featured Replies

I've hit a snag using PatternCount to count values within a list for a summary chart and hope someone can point me in the direction of an alternative solution... 

Here's my problem: I have a summaryReferralReason Summary field which is a List of the referralReasons field, which can contain 5 different unique values selected from a drop-down list and are the subject for a simple bar chart in my summary layout. I couldn't understand why adding up the totals for each of these 5 values in my bar chart were different from the summarised total (which is simply a count of all values) and then it twigged... d'oh!!

Here are the first three lines of the calculation I've used to generate the chart data... 

PatternCount ( contacts::summaryReferralReason ; "Other" ) & ¶ &
PatternCount ( contacts::summaryReferralReason ; "Another Retailer" ) & ¶ &
PatternCount ( contacts::summaryReferralReason ; "Trade Press" )... 

...and I've realised that my problem is that PatternCount will count every instance of 'Another Retailer' in the Summary List because 'another' contains the characters 'other' :( 

Am I missing a straightforward fix that will count exact text strings or will this require some lateral thinking?

Everything else in the summary layout is working a treat so any help or advice with this would be much appreciated! 

will this require some lateral thinking?

​No, just studying the functions that are available … :D Use

List (
  ValueCount ( FilterValues ( contacts::summaryReferralReason ; "Other" ) ) ;
  ValueCount ( FilterValues ( contacts::summaryReferralReason ; "Another Retailer) ) ;
  …

)

But it would be more straightforward to use a related table ReferralReasonsForYourEntity – where each record is one referralReason – and one summary field for referralReason, and use its values for charting. Then you also will automatically summarize the referralReasons that do exist in that table (or in your found set), without having to check for each one that might exist.

  • Author

​No, just studying the functions that are available … :D ​

Thanks for that eos LOL!

Ah yes, FilterValues... I knew it was in there somewhere! Part of the problem with having to dip in and out of FMPro development rather than doing it full time is that my brain can take a bit of time to get back up to speed... :lol: 

Thanks for the heads up on the more straightforward related table option... makes sense.

Just to add other options you could use Exact() instead of PatternCount () in your original calculation.

Or ExecuteSQL ( "SELECT COUNT (Field) FROM Table WHERE Field = ?" ; "" : "" ; "Other" )

Edited by Kris M

  • Author

Just to add other options you could use Exact() instead of PatternCount () in your original calculation.

Or ExecuteSQL ( "SELECT COUNT (Field) FROM Table WHERE Field = ?" ; "" : "" ; "Other" )

​Thanks Kris.

Just to add other options you could use Exact() instead of PatternCount () in your original calculation.

​Not really.

​Not really.

​Thats what i get for not paying attention.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.