Tip

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 first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.