Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
sowmi
Creator
Creator

Selecting two values from single field

Hi everyone,

 

I have a requirement when i select two years then kpi should display value for example i'm trying like this,

 

if(Year='2018' and Year='2019',1,0)

but it is not working ,It is giving 1 only when one of the year is selected from both ,But i want 1 as output when both the years are selected .Please share your views on this .

 

Labels (2)
1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

please elaborate more. what did you try.
i checked below and it works

=If(GetSelectedCount(Year)=2 and Match(Concat(Year,','),'2018,2019'),1,0)

View solution in original post

7 Replies
dplr-rn
Partner - Master III
Partner - Master III

Is this in a join object?

If so your expression will not work because using Year like that is same as using Only(Year) which mean s it will return value only if one value is possible.

So you will need to use something like below

getselectedcount(Year)=2 and match(concat(year), 2018, 2019)

Typiing on phone so unfortunately can't give exact syntax

sowmi
Creator
Creator
Author

Hi!

It is not working .

 

 

dplr-rn
Partner - Master III
Partner - Master III

please elaborate more. what did you try.
i checked below and it works

=If(GetSelectedCount(Year)=2 and Match(Concat(Year,','),'2018,2019'),1,0)
martinpohl
Partner - Master
Partner - Master

edit:

change to

getselectedcount(Year)=2 and match(concat(distinct Year,','), '2018,2019')

Regards

sowmi
Creator
Creator
Author

i am giving  expression like this :

If(GetSelectedCount(Year)=2 and Match(Concat(Year,','),'2018','2019'),1,0) ,Now i removed the single quotes and it is working 

Can you please know me y it is not working if i giving single quotes for the year

Thanks

Sowmya

dplr-rn
Partner - Master III
Partner - Master III

if you give string like this '2018,2019' it will work because match function checks for whole string. and output of concat is 2018,2019

you could use wildmatch as well like below. this is similar to match but also takes wildcards

e.g.

WildMatch(Concat(Year,','),'*2018*','"2019*')

dplr-rn
Partner - Master III
Partner - Master III

mark as answered and close the thread. if its cleared up