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: 
tinkerz1
Creator II
Creator II

2 LIKEs in a function and a get field expression

Hi,

Where am i going wrong? I want to set up an expression to capture fields selection in ABC, I know using a LIKE the OHL and RED are unique, but I cant see how to get the LIKE function working

Sum({$<[ABC]=({$<[{getfieldselections([ABC]) LIKE '*OHL*,*RED*'}>]data)

plus how do I paste code, the insert>plain does not seem to be working???

Is there a tutorial?

Thanks,

Neil.

10 Replies
PrashantSangle

Hi,

try this

Sum(if(wildmatch(getfieldselections([ABC]),'*OHL*,*RED*'),data))

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
maxgro
MVP
MVP

try

Sum({$ <[ABC]={"*OHL*", "*RED*"}>} data)

tinkerz1
Creator II
Creator II
Author

Hi,

When I call the field with the full name this works

sum({$<[ABC]={[Red Threshold (OHL)]}>}Data)

but not with the Like function

Sum({$ <[ABC]={"*OHL*", "*Red*"}>} data)

Any ideas

Neil

maxgro
MVP
MVP

I understood you want to sum data when ABC like OHL or Red

data and ABC are fields

OHL Red values of ABC field

awhitfield
Partner - Champion
Partner - Champion

Hi Neil,

see the attached simple example, =Sum({$ <[ABC]={ "*ohl*","*red*"}>} data)
works fine in this case.

HTH - Regards,

Andy

tinkerz1
Creator II
Creator II
Author

What I would like is to sum when OHL and RED in the same filed.

The above statement will sum all reds regardless of OHL in the field.

petter
Partner - Champion III
Partner - Champion III

Yes - the above statement is an OR not an AND.

If you need an AND logic you will have to use intersection between record sets and not the element sets.

Something like this might work for you:

=Sum( { $<[ABC]={"*ohl*"}> * $<[ABC]={"*red*"}> } data )

maxgro
MVP
MVP

try with intersection

sum( {$ <ABC={"*RED*"}*{"*OHL*"}>}  data)

awhitfield
Partner - Champion
Partner - Champion

Gotcha,

you mean =Sum({$ <[ABC]={ "*RED*OHL*"}>} data)

HTH Andy