Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

JustinDallas
Valued Contributor

Match List in If Statement

Hello Everyone,

I've got a UI where my expression for my dimension used to look like this

If(stp_event = {'IEMT'},

  [Origin City],

    Null()

)

This worked like a charm, but then I found out that I have more "stp_event"s to match against for my requirement.  So I then went and did this.

LET.PNG

And then in my UI.  I have this statement which doesn't work.

LETNOT.PNG

Mind you, the UI behaves as expected when vEmptyBlahBlah = 'IEMT' just not when I add that ,BBT.

Any help is greatly appreciated.

6 Replies
aarkay29
Valued Contributor

Re: Match List in If Statement

May be this:

If(Stp_Event =Subfield($(VEmptyStopEventTypes),',',1) Or Stp_Event =Subfield($(VEmptyStopEventTypes),',',2) , [Origin City], Null())

antoniotiman
Honored Contributor III

Re: Match List in If Statement

Hi Justin,

try

SET vEmptyStopEventTypes = 'IEMT','BBT' ;

If(Match(Stp_Event,$(vEmptyStopEventType)),[Origin City],Null())

Regards,

Antonio

passionate
Valued Contributor

Re: Match List in If Statement

HI,

Please use this expression:

Pick(Match(stp_event,'IEMT','BBT')+1,'Null()','[Oigin City]','[Oigin City]')

Regards,

Pankaj

Re: Match List in If Statement

try like below

change variable

LET vEmptyStopEventTypes='IEMT','BBT'

then try below

If(match(stp_event , $(vEmptyStopEventTypes)),

[Origin City],

Null()

)

MVP
MVP

Re: Match List in If Statement

Hi Justin,

If there are multiple values then you have use Match() like below

  1. If(Match(stp_event, $(vEmptyStopEventTypes))
  2.   [Origin City], 
  3.     Null() 
  4. )

It is always better to avoid calculated dimension because of performance issues, instead you can solve this by using set analysis like below

Dimension: stp_event

Expression: Sum({<stp_event={$(vEmptyStopEventTypes)}>} FieldName)

Hope this helps you.

Regards,

jagan.

JustinDallas
Valued Contributor

Re: Match List in If Statement

Hi Antonio,

This is the correct answer, the SET part is key.  But I don't seem to be able to mark this as "Correct Answer".

Community Browser