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.

Calculating total items in a value list

Featured Replies

  • Newbies

I tried to post this earlier today, but since I don't see it up, I'm assuming it didn't work. Apologies if this is a duplicate.

I'm trying to find a way to add up all unique entries in my field "authors," and since its value list is drawn from the field, eliminating duplicates, I wondered if there is a way to just calculate the total number of items on that value list. How would I do that? Or is there a better way?

Thanks for any advice,

Athena

Items in a value list are paragraph separated -- the paragraphs are between values, but not at the beginning or end of the list. From this we can make the following observations:

1) if the value list is empty there are 0 paragraphs.

2) if there is one value there are 0 paragraphs.

3) if there are 2 values there is 1 paragraph.

4) if there are 3 values there are 2 paragraphs.

Frommthis we generalise:

a) if there are 0 paragraphs there may be 0 or 1 values.

: if there are N paragraphs there are N+1 values.

So your logic needs to first check whether the value list is empty: if it is there are 0 values; if it is not, count the number of paragraphs and add 1 to the number.

Case(

IsEmpty( valuelist ), 0,

PatternCount( valuelist, par.gif ) + 1 )

)

For completeness, and for others that may read this, you get your value list into a field using the ValueListItems() function... specifically for a value list in the current file you'd use

ValueListItems( Status( CurrentFileName ), "ValueListName" )

The Status( CurrentFileName ) function avoids having to hard-code the name of the file into the calculation, which is good because such hard-coded strings are not changed by the Developer tool when renaming files.

  • Author
  • Newbies

Thanks so much for walking me through it.

It works great; however now I have a 500 line list associated with every record and my file size has quintupled.

I feel like such a novice here, but is there a way to avoid this, to make the calculation result global?

Thanks again.

Hi,

What is the exact purpose of this field ?

Having a ValueListItems function on any record surely slows things.

  • Author
  • Newbies

What I'm trying to do is come up with a running total of unique items in my field called "authors".

If there's a way to do it without the value list, I'm all for it.

Since the value list calculation must be unstored in order to update, it will slow your file down if you have the field on each record. If you aren't opposed to scripting it and possibly having an Update button for it, setting a global with the calculation would be much more efficient.

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.