There are a number of prefixes in QlikView, that help you load and transform data. One of them is the Crosstable transformation.
Whenever you have a crosstable of data, the Crosstable prefix can be used to transform the data and create the desired fields. A crosstable is basically a matrix where one of the fields is displayed vertically and another is displayed horizontally. In the input table below you have one column per month and one row per product.
But if you want to analyze this data, it is much easier to have all numbers in one field and all months in another, i.e. in a three-column table. It is not very practical to have one column per month, since you want to use Month as dimension and Sum(Sales) as measure.
Enter the Crosstable prefix.
It converts the data to a table with one column for Month and another for Sales. Another way to express it is to say that it takes field names and converts these to field values. If you compare it to the Generic prefix, you will find that they in principle are each other’s inverses.
The syntax is
Crosstable (Month, Sales) Load Product, [Jan 2014], [Feb 2014], [Mar 2014], … From … ;
There are however a couple of things worth noting:
Crosstable (MonthText, Sales)
Load Product, [Jan 2014], [Feb 2014], … From Data;
Date(Date#(MonthText,'MMM YYYY'),'MMM YYYY') as Month,
Drop Table tmpData;
Finally, if your source is a crosstable and you also want to display the data as a crosstable, it might be tempting to load the data as it is, without any transformation.
I strongly recommend that you don’t. A crosstable transformation simplifies everything and you can still display your data as a crosstable using a standard pivot table.