Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
qlikconsultant
Contributor II

Why i can't count in a variable in the load script?

Hi I have the following code in the load script:

LET vCountCustomers=count(distinct usercode);

But as result i get nothing.

Tags (2)
1 Solution

Accepted Solutions

Re: Why i can't count in a variable in the load script?

I guess this functionality is not directly available, but if you want, you can calculate Count() in a table load and then store its value in a variable using Peek() function....

Temp:

LOAD count(distinct usercode) as CountCust

Resident SomeTable;


LET vCountCustomers = Peek('CountCust');

DROP Table Temp;

View solution in original post

3 Replies
MVP & Luminary
MVP & Luminary

Re: Why i can't count in a variable in the load script?

Try it with: LET vCountCustomers = fieldvaluecount('usercode')

- Marcus

Re: Why i can't count in a variable in the load script?

I guess this functionality is not directly available, but if you want, you can calculate Count() in a table load and then store its value in a variable using Peek() function....

Temp:

LOAD count(distinct usercode) as CountCust

Resident SomeTable;


LET vCountCustomers = Peek('CountCust');

DROP Table Temp;

View solution in original post

Re: Why i can't count in a variable in the load script?

Indeed. In a Load Script, aggregation functions like Sum(), Count() Min(), Max() and the others only work if they are used in a LOAD or SQL SELECT statement. AFAIK they don't even work on Fields, just on Table Columns.