Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

help with if statement.....

[stupid question alert]

I got this in my load statement.

  left(subfield(FileName(),'Open',2),8) As Test1,

  if(left(subfield(FileName(),'Open',2),8) = 'Changes','CHG','INC') As Test2

  and getting this result...


what do I do wrong....

2 Replies
New Contributor III

Re: help with if statement.....

left(subfield(FileName(),'Open',2),8) will return 8 characters, but Changes is only 7 characters. So you'll either need to adjust your Left() to be 7 instead of 8, or adjust 'Changes' to whatever left(subfield(FileName(),'Open',2),8) returns.


Re: help with if statement.....

Try this:

If(Trim(Left(SubField(FileName(),'Open',2),8)) = 'Changes','CHG','INC') As Test2


If(WildMatch(Left(SubField(FileName(),'Open',2),8), '*Changes*'),'CHG','INC') As Test2