Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

distinct row count

below is the sample table

CAL:

Load * INLINE [

days,no

Jan,1

Feb,1

Mar,3

Apr,2

May,4

Jun,4

Jul,5

Aug,6

Sep,7

Oct,8

Nov,9

Dec,5

];

i want to get thhe distinct count of column "no"

at script level i am using

let vvar = count(DISTINCT no);

trace >>> countof: $(vvar);


but log file show null


plz provide any solution for the same the required answer should be "9"

1 Solution

Accepted Solutions
its_anandrjs

Try this way

CAL:

LOAD * INLINE [

    days, no

    Jan, 1

    Feb, 1

    Mar, 3

    Apr, 2

    May, 4

    Jun, 4

    Jul, 5

    Aug, 6

    Sep, 7

    Oct, 8

    Nov, 9

    Dec, 5

];

//Add this table for distinct count

Cnt:

LOAD

count(DISTINCT no) as No

Resident CAL;

let vvar = Peek('No',0,'Cnt');  //And store in this variable

trace >>> countof: $(vvar);

Regards

View solution in original post

5 Replies
its_anandrjs

Try this way

CAL:

LOAD * INLINE [

    days, no

    Jan, 1

    Feb, 1

    Mar, 3

    Apr, 2

    May, 4

    Jun, 4

    Jul, 5

    Aug, 6

    Sep, 7

    Oct, 8

    Nov, 9

    Dec, 5

];

//Add this table for distinct count

Cnt:

LOAD

count(DISTINCT no) as No

Resident CAL;

let vvar = Peek('No',0,'Cnt');  //And store in this variable

trace >>> countof: $(vvar);

Regards

Not applicable
Author

why we need to create a new table (i.e Cnt)?, why it is not possible with "count" command directly

sujeetsingh
Master III
Master III

You can easily get this done in the UI.

For script just Anand has provided a sample solution.

its_anandrjs

If manually you create the variable in the front end then you can easily achieve with expression

vvar = count(DISTINCT no);

But in load script you have to refer the table directly.

sujeetsingh
Master III
Master III

That is from UI