Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Re: distinct row count

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

5 Replies

Re: distinct row count

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

Re: distinct row count

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

sujeetsingh
Honored Contributor III

Re: distinct row count

You can easily get this done in the UI.

For script just Anand has provided a sample solution.

Re: distinct row count

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
Honored Contributor III

Re: distinct row count

That is from UI

Community Browser