December 2, 200421 yr 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
December 2, 200421 yr 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, ) + 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.
December 2, 200421 yr 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.
December 2, 200421 yr Hi, What is the exact purpose of this field ? Having a ValueListItems function on any record surely slows things.
December 2, 200421 yr 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.
December 2, 200421 yr 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