

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- load scripts
- variales
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try it with: LET vCountCustomers = fieldvaluecount('usercode')
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
