Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
infock12
Creator III
Creator III

Using COUNT and BETWEEN function together

Hello all,

Good morning! I would like to use COUNT and BETWEEN function together. I am trying to count the total number of questions and apply another condition. For example,

if(count(Questions)>"=4 <=7", if(Count({<Marks = {'10'}>}Questions)>=3, if(Count({<Marks = {'7', '8', '9', '10'}>}Questions)>3, 'Excellent', 'Good.'

I wanted to say if the total number of questions are between 4 and 7, and

if >3 questions have more than 10 marks,

and if the rest all the questions have more than 7 marks, say 'Excellent', otherwise 'Good'.

Two questions:

1. The above function does not work, and it seems that the problem lies in the first IF and between,  i.e., [if(count(Questions)>"=4 <=7"]. If I apply if(count(Questions)>=3, it works.

2. The third IF statement, i.e., if(Count({<Marks = {'7', '8', '9', '10'}>}Questions) works fine, but how can I count the marks that are more than 7? Rather than saying Marks={'7', '8', '9', '10'}. When I gave {>7}, it does not work.

t doesn't stop there, I will have to write this for questions less than 4, and questions more than 7 but if I can get the first part right, I can build the rest.

Thanks for your help in advance.

13 Replies
sunny_talwar

I am not sure I completely understand your conditions. Would you be able to list out all possible conditions with there expected results if there are not too many of them. For instance with this if statement

=if(count(Questions)>=10 AND  count(Questions)<20 and Count({<Marks = {'10'}>}Questions)>=2, 'Excellent',

if(count(Questions)>=20 AND  count(Questions)<40 and Count({<Marks = {'10'}>}Questions)>=4, 'Excellent',

if(count(Questions)>=40 AND  count(Questions)<63 and Count({<Marks = {'10'}>}Questions)>=4, 'Excellent',

if(count(Questions)>=10 AND  count(Questions)<20 and Count({<Marks = {'>=7 <=9'}>}Questions)>=3, 'Good',

'Insufficient'))))

The first statement means that

  • If Count of questions is between 10 and 19 and if the Mark 10 Scores are more than 2 then its excellent.

Likewise can you list all your conditions....

infock12
Creator III
Creator III
Author

Sorry for not being so clear.

You have got the first statement right, which is

If Count of questions is between 10 and 19 and if the Mark 10 Scores are more than 2 (AND IF ALL THE REST OF THE QUESTIONS HAVE MARKS BETWEEN 7 AND 9) then it is excellent, otherwise 'Good' - I have added the condition I wanted to add in brackets and capitalised.

I tried the below and it works but wanted to confirm if it is the right way to go? Or if there is an alternative way?

if(count(Questions)>10 AND count(Questions)<20 AND count({<Rating = {'10'}>}Questions)>=2 and Count({<Rating = {'>=7 <=9'}>}Questions)=('>=3 <20'), 'Excellent', 'Good'))))

The whole exercise is a bit complicated and it keeps evolving as I go along!

sunny_talwar

Try if this works:

If((Count(Questions)>10 and Count(Questions)<20 and Count({<Rating = {'10'}>} Questions)>=2) or

   (Count({<Rating = {'>=7<=9'}>} Questions) >=3 and Count({<Rating = {'>=7<=9'}>} Questions) <20), 'Excellent', 'Good'))))

infock12
Creator III
Creator III
Author

Hi,

Sorry, connecting with OR statement didn't work, but the one I sent in the earlier post works fine.

=if(count(Questions)>10 AND count(Questions)<20 AND count({<Marks = {'>=7 <=9'}>}Questions)<=3 and Count({<Marks = {'>=5 <=6'}>}Questions)>=2 and Count({<Marks = {'>=5 <=6'}>}Questions)<=4, 'Excellent', 'Good')

Typed in as Rating instead of Marks in my previous post.