Sorting or indexing using a computed key field

If the format of the data in a physical key field prevents the accurate sorting or indexing of a table, you may be able to achieve accurate results by creating a computed key field. Examples of data format impeding sorting or indexing include numbers that inconsistently contain non-numeric prefixes or leading blanks, and names that are inconsistently capitalized. You can create a computed key field to make the data consistent, and then sort or index using the computed key field.

You can also sort or index using a computed key field to order tables in ways other than a strictly sequential ordering of key field values. For example, you can use a computed key field to reverse the physical order of records in a table, group even dollar values, or group names that contain a particular string.

Make the computed key field values visible

A best practice when indexing using a computed key field is to add the computed field to the view so that you can see exactly how the computed values are being used to index the table. When you sort using a computed key field, the computed field is automatically included in the new, sorted table.

It is possible to directly incorporate expressions in the sorting and indexing operations, and achieve the same results that you can achieve with a computed key field. However, this approach is not recommended because it hides the computed values that are being used to order the table.

Examples of sorting or indexing using a computed key field

Several examples of sorting or indexing using a computed key field appear below. For comparison, the non-computed, sequential order of the physical key field is also included.

Steps

The steps for sorting or indexing a table using a computed key field are explained in general terms below.

For detailed information about creating computed fields, and performing sorting or indexing, see the relevant sections of this guide.

  1. Using an appropriate expression, create a computed key field based on the sort or index physical key field.
  2. If you are going to perform an indexing operation, add the computed key field to the view.
  3. Using the computed field as the key field, perform the regular sorting or indexing procedure.
    • If necessary, specify a descending order for the computed key field. Some expressions require a descending order to position results at the top of the table.
    • If you want to sequentially order results within groupings created by the computed key field expression, select both the computed key field and the physical key field when sorting or indexing. Make sure to select the computed key field first, so that it takes precedence over the physical key field.
Analytics 14.1 Help