Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load script

Hi all,

Can i load only the counts of values in a column from the DB instead of loading the whole column.

For example: I have login table where we will save the user details like user_id, login_date, and some more... every time when user logged in.

Now i need just count(user_id) which give the number of logins.

My scenario is instead of loading the whole data, i need to apply set analysis in the load script itself.

Is all functions like max, sum, count can be used in load script  in Qlik sense?

Regards,

Kumar

7 Replies
tresesco
MVP
MVP

You can use all the functions you mentioned, but not Set Analysis in the script. However, that you should not be worried about, because you can achieve your goal  in the script without that. Try like:

Load

          user_id,

          Count(user_id) as user_count

from <> Group By user_id;

'Group By' is important when using any aggregation function in the script. Learn about it.

Anonymous
Not applicable
Author

Yes, you can use all mentioned function at script level. As these function are aggregate function so you need to group them which you can do by Group By.

Set Analysis is used at front end not at script level, but yeah as tresesco‌ mentioned their are alternates to achieve your goal with the same output as it is done by Set Analysis at UI level, same you can achieve at script level too.

Not applicable
Author

I don't want load user_id, but only Count(user_id) as user_count.

Is this possible?


tresesco
MVP
MVP

Possible. Try it and let know if any issues.

Not applicable
Author

NO, I am getting error as odbc failed...

ogster1974
Partner - Master II
Partner - Master II

screen shot your piece of script and tell us the type of database you are using.  So people can help you better.

ogster1974
Partner - Master II
Partner - Master II

For example

[UserVisit]:

LIB CONNECT TO [Your DB];

LOAD [NumberVisits];

SQL SELECT COUNT(user_id)

FROM db.dbo.LoginTable;

Should get you the answer you want with a little tweeking