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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikconsultant
Creator III
Creator III

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.

1 Solution

Accepted Solutions
sunny_talwar

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
marcus_sommer

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

- Marcus

sunny_talwar

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;

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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.