Home arrow Kognitio examples arrow Simple pivot operation

CONTENT WARNING

This site refers to our older, server-based product. If you are interested in our new, Excel-based product, please see our main web site at http://www.nextanalytics.com

Simple pivot operation

kognitio_e3_thumb.pngThe most popular data analysis operation is to convert the results of a SQL query to a crosstab. 

Crosstabs make it easy to perform filtering, aggregation, and to visualize the data in a chart.  Often, users want to export their crosstabs to Microsoft Excel.

SQL doesn't have a crosstabs feature

Even though it is in such high demand, SQL has no built-in means to create crosstabs.

Microsoft added a Pivot command to its SQL Server line, you are required to hard-code data values.  This makes it not very useful.  Microsoft Excel can create Pivot Tables, but the UI is not easy, and it doesn't handle normal production volumes of data very well.  Business Intelligence vendors all having reporting and OLAP tools to create crosstabs but the price is very high. 

Nextanalytics reads SQL query results and makes the creation of crosstabs easy without a lot of overhead.

Priority 1: Keep your schema simple

First, Nextanalytics enables a simplified schema. In some cases, you you will not even need a separate table or reporting database because Nextanalytics can optionally take snapshots of data using a proprietary high perofrmance file thereby eliminating the need for a database modification.

Priority 2: Simplify the SQL 

Second, simple SQL queries can be used because Nextanalytics supports sequential processing which makes it far easier to develop reports than designing and implementing the "query from hell" a task that occupies a fair amount of time and budget in most companies.

In short, nextanalytics offers an easy alternative to create crosstabs, and it eliminates the overhead of creating and maintaining reporting tables, complex queries, cubes, metadata or pivot tables.

Working Example: Change tabular query results into a crosstab "by week"

We start with a simple SQL query to the Kognitio WX2 server with the results shown below.

kognitio_e3a.png

To make a crosstab, we will move the contents of the text column SALEWEEK to a new set of columns.

The values in the SALES column will automatically be placed under the correct week.  If there were more than one data column, then separate crosstabs would be made for each one.  Once the crosstab is completed, the SALEWEEK column itself is no longer needed and is deleted.

If there were multiple records that have a matching SALEWEEK value, then it is your choice to Sum them or choose another math operation. (Sum is the most popular).

The final optional step would be to sort the columns if a custom arrangement is desired.

This is what happens when a crosstab is created. 

kognitio_e3b.png

You can't do crosstabs with SQL but if you follow your SQL query with a short side step to Nextanalytics, it is easily done.  It's as simple as that.  The alternatives are cumbersome and expensive.