Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ferha_jafri
Partner - Creator III
Partner - Creator III

not able to understand n in the query

Hi ,

I was going throgh the manual and i am not able to understand the meaning of 'n' the query mentioned below :

crosstable(attribute field,data field[,n](loadstatement/selectstatement).

Plz help me to understand this with an ex.

Thanks in advance

2 Replies
swuehl
MVP
MVP

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

Examples:

Crosstable (Month, Sales) Load Customer, Jan, Feb, Mar, Apr from ex1.csv;

Resulting table contains fields Customer, Month and Sales.

Crosstable (Month,Sales,2) Load  Customer, SalesRep, Jan, Feb, Mar, Apr from ex2.csv;

Resulting table contains fields Customer, SalesRep, Month and Sales.

So n denotes the number of fields that are not transformed, counting from the beginning of your LOAD / Select field list.

Gysbert_Wassenaar

The n is the number of columns on the left that should stay as they are.

crosstable(Month, Value, 2)

LOAD

Customer,

Region,

Jan,

Feb,

Mar,

....etc

from mytable;

In the above example we want to keep the fields Customer and Region as they are and transform the month columns to two fields named Month and Value. Because we want to keep two fields are they are the n value for the crosstable function is 2.

crosstable(Month, Value, 3)

LOAD

Customer,

Region,

SalesPerson,

Jan,

Feb,

Mar,

....etc

from mytable;

In this example there are now three fields we like to keep as they are, so the n value for the crosstable function is now 3.


talk is cheap, supply exceeds demand