Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
gouthamkk
Creator
Creator

Variable value

Hi Experts,

In the backend scripting, I would like to get count of distinct id into a variable. Can some one help me in getting it?

Eg:

Load Count(distinct(id)  as flag;

sql select * from demo;

Till here every thing is fine.

No I need to save the flag values in a variable

Request to assist

Thanks Kumar

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Load Count(distinct(id)  as flag;

sql select * from demo;

LET vCount = peek('flag');

But you don't need to do it this way. Qlikview keeps track of distinct values of its internal tables and there are (very fast) functions to use such information:

sql select * from demo; // this assumes you load a field called id.

LET vCount = fieldvaluecount('id'); // get the number of distinct values from Qlikviews internal field tables.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

Load Count(distinct(id)  as flag;

sql select * from demo;

LET vCount = peek('flag');

But you don't need to do it this way. Qlikview keeps track of distinct values of its internal tables and there are (very fast) functions to use such information:

sql select * from demo; // this assumes you load a field called id.

LET vCount = fieldvaluecount('id'); // get the number of distinct values from Qlikviews internal field tables.


talk is cheap, supply exceeds demand
gouthamkk
Creator
Creator
Author

HI,

Thanks a lot for the additional input. I think I will go with your second thought on Internal tables. Both the logics works fine and are giving same results

thanks

Kumar