Skip to main content
Announcements
New: No-code data prep in Qlik Cloud Analytics™ TAKE A TOUR
cancel
Showing results for 
Search instead for 
Did you mean: 
johngouws
Partner - Specialist
Partner - Specialist

Greater than equal to >= in load script

Good day all. 

I normally use >= in my set analysis but am wondering if there is a way of using >= in the load script? 

Thank you - stay safe..

Labels (1)
1 Solution

Accepted Solutions
Mauritz_SA
Partner - Specialist
Partner - Specialist

I suspect that your Document Type is being seen as text. Try IF(Physical='1' and SearchType='4' and Num#(DocumentType)<=5,DiscountAmount) as [Total_Sale]

You could also use Match(DocumentType,3,4,5) if you want to fix the range. Might need to use Match(Num#(DocumentType),3,4,5).

View solution in original post

13 Replies
tresesco
MVP
MVP


@johngouws wrote:

....

Thank you - stay safe..


Yes. This is very important now across the world. Thank you. STAY ISOLATED, STAY SAFE, Keep others safe.

Coming back to your question. You can use the same comparison operator '>=' or '<=' in the script. If you are facing issue, it could be because of the way you are trying. You can share your issue.

Mauritz_SA
Partner - Specialist
Partner - Specialist

Hi @johngouws 

You can use it as is. For example: If(Sales>=200,'Big','Small') Just make sure that the field you are evaluating has the same format as the value you are comparing it to (num if comparing to a num or date when comparing to a date).

LOAD *,

If(Date<'2013/02/01','Pre Feb 2013','Post Feb 2013') AS [Date Group],

If(Sales>=200,'Big','Small') AS [Sale Size]

Inline [
Date,Sales
2012/12/02,400
2013/01/01,880
2013/02/01,90
2013/03/01,370
];

Hope this helps.

Regards,

Mauritz

johngouws
Partner - Specialist
Partner - Specialist
Author

Thank you  for responses. 

I am doing something 'st??pid! This is what I am doing in the script: 

IF(Physical='1' and SearchType='4' and DocumentType='3' ,DiscountAmount*-1,DiscountAmount) as [Total_Sale]

Please where is the issue..

 

Mauritz_SA
Partner - Specialist
Partner - Specialist

Hi John

The syntax looks right. What is the issue that you're experiencing? Maybe you could post a snippet of the straight table with Physical, SearchType, DocumentType, DiscountAmount and [Total_Sale] in it?

tresesco
MVP
MVP

It looks fine. Now you have to tell us 'where is the issue' and where is '>=' ?

johngouws
Partner - Specialist
Partner - Specialist
Author

Apologies,  

What I am trying to do is replace the (DocumentType='3' or DocumentType='4' or DocumentType='5') with DocumentType<='5'. 

If I use: 

IF(Physical='1' and SearchType='4' and (DocumentType='3' or DocumentType='4' or DocumentType='5') ,DiscountAmount) as [Total_Sale] I get a different result to when I use 

IF(Physical='1' and SearchType='4' and (DocumentType<='5') ,DiscountAmount) as [Total_Sale]

 

Mauritz_SA
Partner - Specialist
Partner - Specialist

Are you sure you don't have a Document Type smaller than 3?

johngouws
Partner - Specialist
Partner - Specialist
Author

Yes I am sure

tresesco
MVP
MVP

Could you share a sample reproducing the issue?