Crosstab Enhancements
\The Sandbox \PB History & Future \New in PB 4 \DW and Reporting \Crosstab Enhancements
Two Types of
Crosstabs
Creating
Crosstabs

Cross tabulation is a useful technique for analyzing data. By presenting data in a spreadsheet-like grid, a crosstab lets you view summary data instead of a long series of rows and columns.

For example, in a sales application you might want to summarize the quarterly unit sales of each product.

In PowerBuilder, you create crosstabs by using the crosstab DataWindow presentation style. When data is retrieved into the DataWindow, the crosstab processes all the data and presents the summary information that you have defined for it.

An example

Crosstabs are easiest to understand through an example. Consider the Printer table, which is in the Powersoft Demo Database. It records quarterly unit sales of printers made by sales representatives in one year (this is the same data used in the documentation to illustrate graphs).

Rep

Quarter

Product

Units

Simpson

Q1

Stellar

12

Jones

Q1

Stellar

18

Perez

Q1

Stellar

15

Simpson

Q1

Cosmic

33

Jones

Q1

Cosmic

5

Perez

Q1

Cosmic

26

Simpson

Q1

Galactic

6

Jones

Q1

Galactic

2

Perez

Q1

Galactic

1

.

.

.

.

.

.

.

.

.

.

.

.

Simpson

Q4

Stellar

30

Jones

Q4

Stellar

24

Perez

Q4

Stellar

36

Simpson

Q4

Cosmic

60

Jones

Q4

Cosmic

52

Perez

Q4

Cosmic

48

Simpson

Q4

Galactic

3

Jones

Q4

Galactic

3

Perez

Q4

Galactic

6

This information can be summarized in a crosstab that shows unit sales by printer for each quarter.

What crosstabs do

Crosstabs perform two-dimensional analysis:

  • The first dimension is displayed as columns across the crosstab.
  • In the preceding crosstab, it is the quarter, whose values are in the Quarter column in the database table.

  • The second dimension is displayed as rows down the crosstab.
  • In the preceding crosstab, it is the type of printer, whose values are in the Product column in the database table.

Each cell in a crosstab is the intersection of a column (the first dimension) and a row (the second dimension). The numbers that appear in the cells are calculations based on both dimensions. In the preceding crosstab, it is the sum of unit sales for the quarter in the corresponding column and printer in the corresponding row.

Crosstabs can also include summary statistics. The preceding crosstab totals the sales for each quarter in the last row and the total sales for each printer in the last column.

How crosstabs are implemented in PowerBuilder

Crosstabs in PowerBuilder are implemented as grid DataWindows. Because crosstabs are grid DataWindows, you can resize and reorder columns when you run the crosstab.

Running a crosstab
You run a crosstab by previewing it in the DataWindow painter and by running it from an executable file.

See also

Two types of crosstabs

Creating crosstabs 

PBL Peeper PB Help PB History
& Future About Us Feedback Site Map

Google
 
Web www.techno-kitten.com
www.sybase.com