Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

problems with count

Hi There,

I am having issues  in getting the count statement

My expression is that count ({<NYEAR=mainyear>} distinct num)   . When  a filter is applied it work else it show 0 .

How can this be corrected. Please help .

regards

varghese

1 Solution

Accepted Solutions
jonathandienst

Hi

If mainyear is another field and you are trying to do row-by-row calculations, you cannot use a set expression, as the expression is evaluated once for the table/chart and not on every row.

You can do sum(if(NYEAR = mainyear, DISTINCT num)),

or

You can create a flag field in the load script:

     LOAD ....

          NYEAR,

          mainyear,

          If(NYEAR = mainyear, 1, 0) As YFlag,

          ....

     and then use the flag in your expression:

     Sum({<YFlag = {1}>} Distinct num)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
jonathandienst

Hi

If mainyear is another field and you are trying to do row-by-row calculations, you cannot use a set expression, as the expression is evaluated once for the table/chart and not on every row.

You can do sum(if(NYEAR = mainyear, DISTINCT num)),

or

You can create a flag field in the load script:

     LOAD ....

          NYEAR,

          mainyear,

          If(NYEAR = mainyear, 1, 0) As YFlag,

          ....

     and then use the flag in your expression:

     Sum({<YFlag = {1}>} Distinct num)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

Not applicable
Author

Dear Jonathan

Thanks , It worked.

regards

Varghese

Not applicable
Author

count (distinct {<NYEAR={'mainyear'}>} num)