Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use greater than, less than and equal to in qlikview expression

Dear All,

Hi, im new to qlikview so im not familiar with the expression script. Im doing a grade distribution project and one of the criteria is that i have to calculate the percentage of student with grade 'A'.

Criteria:

%modules >  30% A

%module > 40% A

%module > 60%(A + B)

%module < 10% A

im not sure how to write the syntax.

E.g "Count #A > 30% / count all A"

Thank you..

10 Replies
MK_QSL
MVP
MVP

Can you provide little sample data...plz

Not applicable
Author

Alright

MK_QSL
MVP
MVP

Based on your enclosed file, let us know what exactly you want....may be logic behind your required output...

jvitantonio
Luminary Alumni
Luminary Alumni

Hi, Here's the formula you are looking for:

=count(if(num#(A, '#,##%') > num#('10%', '#,##%'), 1)) / count(all A)

You can place that in a Text Box and see the result.

JV

Not applicable
Author

The output is something like this as you can see in the image. I apologize for the late replyExample.jpg

Not applicable
Author

Hi, can you pls explain the formula?

jvitantonio
Luminary Alumni
Luminary Alumni

Sure,

The formula itself is very simple although it looks complicated. The base formula is

=count(if(A > 0.1, 1)) / count(all A)


This is saying, Count A, when A is greater than 0,1 (in percentage = 10%) and divide it by counting all A.


In your data model, you store your percentage as TEXT what makes things a bit more complicated, and that's why I need to use the function num#().


This function receives a number in text format and reads it as a value. Otherwise you wouldn't be able to compare A with a string "10%".


So, in the formula when you see:

num#(A, '#,##%') > num#('10%', '#,##%')

you are actually saying: A has a string format (text), it will come formatted as percentage so whenever you read it, please remove the symbol % and treat it as a number.

The above of course, is invisible to you.

I hope this helps.

JV

Not applicable
Author

Hi QL,

Sorry for the late reply. okay your expressions worked but not for the modules. It works for another criteria for my project that is:

Criteria 1:

1. % modules > 30% A

2. % modules > 40% A

3. % modules > 60% A+B

4. % modules < 10% A

_______________________

Criteria 2: Your expression worked for this criteria...

1. % courses > 30% A

2. % courses > 40% A

3. % courses > 60% A+B

4. % courses < 10% A

Thanks for your help

jvitantonio
Luminary Alumni
Luminary Alumni

Hi Rizal,

It should be the same. Would it be possible for you to attach a sample application with your data? It doesn't have to be real data, but it should have the same format.

Thanks,

JV