Manage Learn to apply best practices and optimize your operations.

A Better Way To Rearrange Categories

Suppose you want a Notes view that categorizes documents, but you don't want to
have the categories in alphabetical sequence.

Developers generally do this by adding a hidden sorted column before the
categorized column. An example of such a hidden column formula follows:

REM "Pre-sort documents to control order of categorization";
@If(Status = "Draft"; 1; Status = "Submitted"; 2; Status = "Completed"; 3; 4)

If this is followed by a categorized column that displays the Status field, the
Draft category will appear first, then the Submitted category, then Completed,
then any others in alphabetical order.

However, the hidden sorting formula is more complex than we like to evaluate in
a view, for performance reasons.

You could create a separate computed field in the document using this formula,
but this complicates automated processing of the documents (when an agent
changes the status it must also change the sorting number), and makes
maintenance more difficult since you can't easily reorder the view by changing
the formula.

Here's a way to recapture some of that performance while avoiding storing extra
fields. Use the following as a column formula instead:
REM "Pre-sort documents to control order of categorization (values are listed
in reverse order)";
@Member(Status; "Completed" : "Submitted" : "Draft")

You would then need to sort the column in descending order (this assumes you
want unknown values to appear at the end).

This formula manages to produce the same result as the @If without doing three
separate comparisons, giving better performance. It's also is easier to
maintain, since to add a new value you just need to insert it at the correct
position in the list, instead of reassigning the number codes yourself.

This was last published in November 2000

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...