Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

pls give me a explination about cross table with simple example?

pls give me a explination about cross table with simple example?

9 Replies
Anonymous
Not applicable
Author

Hope this helps

CrossTable.qvw

fkeuroglian
Partner - Master
Partner - Master

Not applicable
Author

sorry i am using personal edition i cant open pls send as a file

MK_QSL
MVP
MVP

Example enclosed.

UPDATE:

Consider that you have customer vs monthly sales data as below..

CustomerCountryJanFebMar
AGermany100200300
BSpain400500250
CItaly350250600

Use below script and you will see how cross table is working..

CrossTable(Month, Sales, 2)

Load * Inline

[

  Customer, Country, Jan, Feb, Mar

  A, Germany, 100, 200, 300

  B, Spain, 400, 500, 250

  C, Italy, 350, 250, 600

];

The table will now looks like below....

Customer Country Month Sales
AGermanyFeb200
AGermanyJan100
AGermanyMar300
CItalyFeb250
CItalyJan350
CItalyMar600
BSpainFeb500
BSpainJan400
BSpainMar250
Anonymous
Not applicable
Author

The cross table is useful when we want to convert our columns into rows.

This is an example of a cross table:

Sales PersonQ1Q2Q3Q4

John

50302010
Mary30105010

During the load the data will be transformed to this format:

Sales PersonQuarterSales
John

Q1

50

Mary

Q130
JohnQ230
MaryQ210
JohnQ320
MaryQ350
JohnQ410
MaryQ410

Load Script:

CrossTable(Quarter, Sales)

LOAD [Sales Rep],

     [Q1 2010],

     [Q2 2010],

     [Q3 2010],

     [Q4 2010],

     [Q1 2011],

     [Q2 2011],

     [Q3 2011],

     [Q4 2011],

     [Q1 2012],

     [Q2 2012],

     [Q3 2012],

     [Q4 2012]

FROM

[Data.xlsx]

(ooxml, embedded labels, table is Sheet1, filters(

Remove(Row, RowCnd(CellValue, 1, StrCnd(contain, 'Total'))),

Replace(1, top, StrCnd(null))

));

Not applicable
Author

crosstable (attribute field , data field [ , n ] )

here what about n what it will do exactly and how to identify which one is attribute field and which one is data field

Anonymous
Not applicable
Author

Crosstable : n signifies the Qualifier fields

CrossTable(Quarter, Sales) by default its 1,its sales person in my example  and

in manish example its Customer and Country,so he assigned 2 to n.

Crosstable will not evaluate qualifier fields and from next field it transforms rows to columns.

aveeeeeee7en
Specialist III
Specialist III

Hi Manoj

In Simple Language

Question: why we use Cross Table?

Answer: We All like to read data in a easier way. So, in order to convert Horizontal Columns into Vertical Rows we use Cross Table Functionality and this increases the readability of data which is easier to understand.

Regards

Aviral Nag

aveeeeeee7en
Specialist III
Specialist III

Brief:

Crosstable

A cross table is a common type of table featuring a matrix of values between two or more orthogonal lists of header data, of which one is used as column headers. A typical example could be to have one column per month. To transform a cross table into a straight table, use a crosstable prefix. The result is that the column headers (e.g. month names) will be stored in one field - the attribute field - and the column data (month numbers) will be stored in a second field: the data field.

The syntax is:

crosstable (attribute field name, data field name [ , n ] ) ( loadstatement | selectstatement )

where:

attribute field name is the field to contain the attribute values.

data field name is the field to contain the data values.

n is the number of qualifier fields preceding the table to be transformed to generic form. Default is 1.

Examples:

Crosstable (Month, Sales) Load * from ex1.csv;

Crosstable (Month,Sales,2) Load * from ex2.csv;

Crosstable (A,B) Select * from table3;

Crosstable Wizard

The crosstable wizard is dialog driven method of creating the crosstable statement. This dialog is opened by clicking the Crosstable button in the Options page of the File Wizard. The crosstable wizard holds the following options:

  

Qualifier Fields

The number of qualifier fields that precede the fields to be transformed.

Attribute Field

The name of the new field that will contain all the fields (attribute values) to be transformed.

Data Field

The name of the new field that will contain the data of the attribute values.