Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

cancel
Showing results for 
Search instead for 
Did you mean: 
kgraham25
Contributor II
Contributor II

Using string with hyphen in it

Hi

I'm trying to set colours on a chart using the following expression:

IF(Age = '<25',

     $(vRed),

     IF (Age = '25-34',

     $(vGreen),

    IF (Age = '35-50',

     $(vYellow),

     $(vGrey)

     )

     )

)


For some reason I don't think it likes the hyphen in the string ('25-34'). Does anyone have any ideas on how to get around this?


Thanks!

1 Solution

Accepted Solutions
petter
Partner
Partner

There is no problem with a hyphen in a string like '25-34'.

Is your Age field a bucketed range already containing the literal strings    '<25' , '25-34' , '35-50' ?

However if your Age field is a number indicating Age then you will have to do this:

If( Age <25 ,

  $(vRed) ,

  If( Agr >= 25 AND Age <=34 ,

    $(vGreen),

    If( Age >= 35 and Age <= 50,

       $(vYellow),

       $(vGray)

    )

  )

)

View solution in original post

5 Replies
sebastian_grah
Contributor II
Contributor II

i fthe hyphen is part of the string try the following:

IF(Age ="'<25'",

     $(vRed),

     IF (Age = "'25-34'",

     $(vGreen),

    IF (Age = "'35-50'",

     $(vYellow),

     $(vGrey)

     )

     )

)

juraj_misina
Luminary Alumni
Luminary Alumni

Hi Kelly,

can you be more specific on what happens or is not working? Hyphens in strings are perfectly OK, but you did not provide any problem description.

Juraj

petter
Partner
Partner

There is no problem with a hyphen in a string like '25-34'.

Is your Age field a bucketed range already containing the literal strings    '<25' , '25-34' , '35-50' ?

However if your Age field is a number indicating Age then you will have to do this:

If( Age <25 ,

  $(vRed) ,

  If( Agr >= 25 AND Age <=34 ,

    $(vGreen),

    If( Age >= 35 and Age <= 50,

       $(vYellow),

       $(vGray)

    )

  )

)

View solution in original post

kgraham25
Contributor II
Contributor II
Author

Thanks Petter - that seems to have worked!

I thought the age bands were string, but turns out they were numbers!

kgraham25
Contributor II
Contributor II
Author

Thanks Sebastian - I hadn't realised that my age variable was actually number and not string.