Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression in Chart


Hi,

I have a expression used in chart.

=if(Match(AD_ID,5001,5032),'KEY Cnt',

only(if(match((AD_ID,>=5004 and <=5019) and (AD_ID,>=5035 and <=5050)),'Prnt Key','TER'))

Could someone tell me what's the error in this expression?

Thanks.

1 Solution

Accepted Solutions
qlikpahadi07
Specialist
Specialist

Hi Gtripathy,

You can achieve by both ways If Else and Match statements. but for Match() you can't give '<=' or '>'... you have to mention all ID but you can create a Variable and make Dynamic Chart for the same.

something like:

=if(Match(AD_ID,$(vVar1)),'KEY Cnt',

    if(Match(AD_ID,$(vVar2)),'Prnt Key','TER'))

Please find the Attachment may be helpful .

View solution in original post

17 Replies
tresesco
MVP
MVP

A quick look finds:

AD_ID,>=5004               // remove comma after AD_ID and similarly from AD_ID,>=5035 as well.

Not applicable
Author

Hi Tresesco,

Thanks for quick reply.I have tried that before.but still there is some error in the expression.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

=if(Match(AD_ID,5001,5032),'KEY Cnt',

only(if(((AD_ID>=5004 and AD_ID<=5019) OR (AD_ID>=5035 and AD_ID<=5050)),'Prnt Key','TER'))

Hope this helps you.

Regards,

Jagan.

tresesco
MVP
MVP

One more:

((AD_ID,>=5004 and <=5019) and (AD_ID,>=5035 and <=5050)) - this is logically impossible. May be you want

((AD_ID>=5004 and <=5019) OR (AD_ID>=5035 and <=5050))

Not applicable
Author

Hi,

it should be OR.but the expression is still having error after the conditional statement ends,it's throwing error.:(. (AD_ID>=5035 and AD_ID<=5050)),'Prnt Key','TER'))

tresesco
MVP
MVP

Add one more ')' at the last and try.

Not applicable
Author

Without Match(), i can build the expression but i need match() as there are no distinct values.so two AD_ID's ll be there.so match() is a must.Please understand that.

=if(Match(AD_ID,5001,5032),'KEY Cnt',

only(if(match((AD_ID>=5004 and AD_ID<=5019) OR (AD_ID>=5035 and AD_ID<=5050)),'Prnt Key','TER')))

Above is the latest expression.

jagan
Luminary Alumni
Luminary Alumni

Hi,

If you want to use Match() then you have to specify each individual value not >= and <=.  Try like this

=if(Match(AD_ID,5001,5032),'KEY Cnt',

only(if(match(AD_ID,5004, 5005, 5006,.... 5019, 5035, 5036, ...........5050), 'Prnt Key','TER')))

Regards,

Jagan.

tresesco
MVP
MVP

Could you post your example app with sample data?