Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Calculating total items in a value list


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

Recommended Posts

  • Newbies
Posted

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

Posted

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.

  • Newbies
Posted

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.

  • Newbies
Posted

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.

Posted

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.

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