Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting multiple values in field in Script

My field name is Expense Type and I want to say

if([Expense Type] = 'Breakfast'  OR [Expense Type] =  'Lunch'  OR [Expense Type] =  'Dinner'  OR [Expense Type] =  'Meals Other' AND [Expense Account] = 'Billable' AND [Total Spend] <= 100,1,0) as FlagMeals.

This is not working but essentially I need each expense type and if its billable and less than 100 total spend then flag as 1...

whats is the correct syntax withing the script editor for something like this?

6 Replies
prabhu0505
Specialist
Specialist

if(

(

(

[Expense Type] = 'Breakfast'  OR [Expense Type] =  'Lunch'  OR [Expense Type] =  'Dinner'  OR [Expense Type] =  'Meals Other'

)

AND

(

[Expense Account] = 'Billable'

)

AND

(

[Total Spend] <= 100),1,0

)

)

as FlagMeals.

Something like this should work. Parentheses instruct which part to execute first.

john9inno
Creator
Creator

you missed brackets but statement was fairly right.

one thing that i don't understand is below.

([Total Spend] <= 100)

isn't it supposed to be ([Total Spend] < 100) as you described less than 100 rather than less or equal to 100.

if(

(

[Expense Type] = 'Breakfast'  OR [Expense Type] =  'Lunch'  OR [Expense Type] =  'Dinner'  OR [Expense Type] =  'Meals Other'

)

AND

([Expense Account] = 'Billable' )

AND

([Total Spend] < 100)

,1,0)

as FlagMeals

Anonymous
Not applicable
Author

If you really need "each expense type and if its billable and less than 100":

if([Expense Account] = 'Billable' AND [Total Spend] < 100,1,0) as FlagMeals

robert_mika
Master III
Master III

if(Match([Expense Type] , 'Breakfast' , 'Lunch', 'Dinner' , 'Meals Other') AND [Expense Account] = 'Billable' AND [Total Spend] <= 100,1,0) as FlagMeals.

should perform better

Feeling Qlikngry?

How To /Missing Manual(18 articles)

Mahamed_Qlik
Specialist
Specialist

Try this,


if(Wild Match([Expense Type] , 'Breakfast' , 'Lunch', 'Dinner' , 'Meals Other') AND [Expense Account] = 'Billable' AND [Total Spend] <= 100,1,0) As FlagMeals

senpradip007
Specialist III
Specialist III

Have got your desired result !!!!