Crosstab Operations

Description

A Crosstab operation takes data from a single table or set and uses it to create a new table, in which certain field values from the transaction table are used as field names in the result table. For example, you have City and Sales data from several companies, as shown below:

images/atable3.png

By using a Crosstab operation, you can create a table that shows the total Sales by City for each Company. The field values in the City field of the master table determine the field names in the result table:

images/atable4.png

Performing a Crosstab Operation

  1. To create a new Crosstab operation:

    On the Operations tab of the Control Panel, click the New button. The Create New Operation dialog box appears.

  2. Select "Crosstab" from the Select Operation list.

  3. Select the table to use from the Table/Set list.

  4. Click the Create button.

  5. Enter the name of the new table in the Result Table Name field. Crosstab Builder:

    images/UG_Crosstab Builder.gif
  6. Selecting Records

    To optionally filter or order the records that the crosstab operation processes, open the Select Records dialog box by clicking the Select Records button on the toolbar.

  7. Make a selection from the list.

  8. Optionally, add filtering (a logical expression ) and ordering (a character expression ) criteria.

  9. Click OK to proceed. Select Records Dialog Box:

    • Crosstab Settings

      The various settings let you determine:

      • Which field is used to create the field names

      • Which field identifies the record

      • Which field is used to create the Crosstab values

      • The records to include in the operation

      • Choosing the Field to Summarize in the Cross-tabulation

        The data in the result table consists of a field or expression that is summarized for each column and row combination. To specify these criteria, enter the field or expression to summarize in the Field/Expression column. Then select the type of summarization operation you want to perform in the Summarization column. You are given the choice of many different types of summarizations, including TOTAL() and AVERAGE().

        Field/Expression
        Summarization
        SALES

        Total

    images/UG_Select_Records_dialog_box.gif
  10. In the Field/Expression column, click the list button 'down pointer' icon to select a field from the source table. In this example, we are selecting "Sales".

  11. In the Summarization column to the right of the field, click the list button 'down' icon to select a summarization function. In this example, we are selecting "Total".

  12. Repeat steps 10 and 11 for other fields you wish to summarize.

    • If you want to summarize an expression, such as Quantity*Cost, instead of a single field, you can either type the expression directly into the Field/Expression column, or choose "" from the drop-down list box. If you choose "", the Expression Builder appears to assist you in creating the expression.

    • Determining the Rows and Columns

      The City field is used to determine the column grouping, while the Company field is used to determine the row grouping. To specify these criteria, the Crosstab Settings is filled in as follows:

    • Field/Expression
      Summarization
      Sales

      Total

      City

      Group by Column

      Company

      Group by Row

  13. In the Field/Expression column, click the list button 'down' icon to select the field that will provide the row heading. In this example, we are selecting "Company".

  14. In the Summarization column to the right of the field, click the list button 'down' icon to select the "Group by Row" function.

  15. In the Field/Expression column, click the list button 'down' icon to select the field that will provide the column heading. In this example, we are selecting "City".

  16. In the Summarization column to the right of the field, click the list button 'down' icon to select the "Group by Column" function.

  17. Repeat steps 15 and 16 if there are other fields that you wish to group by column.

    • Conditions

      The default condition is to include all records from the transaction (source) table in the resulting master (crosstab) table. The Condition column and the OR columns to the right of a field optionally specify filter criteria that allow a record to be included in the crosstab only if they evaluate to TRUE. If you have an entry in one or more of the OR columns, then any these expression that evaluates to TRUE is sufficient to include the record in the crosstab.

    When setting the "Group by Column" and "Group by Row" criteria, you can use an expression instead of a single field. To specify an expression, either type the expression directly into the Field/Expression column, or choose "" from the column's drop-down list box. The Expression Builder appears to assist you in creating the expression.
  18. Optionally, enter expressions in the Condition or the OR columns that select records to include crosstab.

  19. Crosstab Properties

    For additional options, Click the Properties button on the toolbar. Optionally, check Overwrite existing table without asking suppresses the warning message that appears when you run the operation. Suppressing the warning message might be desirable if you wish to avoid confusing someone running your application.

  20. The dictionary file contains, among other things, the forms used to display the crosstab data. Clear Delete pre-existing dictionary file if you wish keep any pre-existing forms.

  21. Check Omit matching records if you wish to invert the logic of the Condition column, so that any record that matches the Condition column or any of the OR columns is excluded from the crosstab. Properties Dialog Box.

    images/UG_Crosstab Properties.gif
  22. Click the Run button on the toolbar to run the operation.

  23. Click OK when the message box tells you how many records will be processed.

Crosstab Genie

  1. Click Next > to continue.

    images/UG_Crosstab_Genie1.gif
  2. In the Group Rows By field, select the field that will provide the row headings in the resulting crosstab table.

  3. Click Next > to continue.

    images/UG_Crosstab_Genie2.gif
  4. Optionally, click the ... button to display the Group By Options dialog. This dialog allows you to:

  5. group on the first N characters of the field's data

  6. group on the first N words of the field's data

  7. Click OK to continue or Cancel to discard your inputs.

  8. Click Next > to continue.

    images/UG_Crosstab_Genie_Group_By_Option.gif
  9. In the Group Columns By field, select the field that will provide the column headings in the resulting crosstab table.

  10. Click Next > to continue.

    images/UG_Crosstab_Genie3.gif
  11. In the Field field, select the field that you will summarize in the resulting crosstab table.

  12. Click Next > to continue.

    images/UG_Crosstab_Genie4.gif
  13. On the Select Records page, choose either:

    • "All records" - analyze all records from the Transaction table.

    • "Current selection of records"

    • "Selected records"

  14. If you selected "Selected records", then make a selection from the list box.

  15. Enter the filter and order criteria required by your choice.

  16. Click Next > to continue.

    images/UG_Crosstab_Genie5.gif
  17. Enter the name of the crosstab (master) table in the Result table field.

  18. Click Next > to continue.

    images/UG_Crosstab_Genie6.gif
  19. Optionally, click Advanced Options to display the Summary Genie dialog box.

  20. Indicate whether you want to warn the operator before overwriting any existing table.

  21. Dictionary files contain, among other things, forms that you might use to view the crosstab data. Indicate whether you want to delete any pre-existing dictionary file.

  22. Click OK to continue or Cancel to discard your inputs.

  23. Click Next > to continue.

    images/UG_Crosstab_Genie_Advanced_Options.gif
  24. Indicate whether you want to run the operation now, save the operation and then run it, or view the settings of the Crosstab Builder.

  25. Click Finish.

    images/UG_Crosstab_Genie7.gif
  26. If you selected Run the Crosstab operation now, (but first save the definition for future use), the Save crosstab settings as... dialog box will appear.

  27. Enter the name of the operation into the Name field and click OK.

  28. If you selected Don't run the Crosstab operation now, just show me how the genie has filled in the Crosstab Builder, the Crosstab Builder will appear.

  29. Optionally, click Save to display the Save crosstab settings as... dialog box.

  30. Enter the name of the operation into the Name field and click OK.

  31. Optionally, click the Run button on the toolbar to run the operation.

Limitations

Desktop Applications Only

See Also