Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
i think this question is very basic and should be easy to solve. So far my googling did not lead me to a solution.
So at the moment i can not find the right syntax for the following problem.
I have a button and i want to show the button ONLY if two specific field values within a field are active.
It works for one value without problems.
E.g. if the "gender" "male" is selected within the field "gender" than i just apply the following condition on the button:
gender=("male")
Now i want to display a button ONLY if BOTH female and male are active.
I thought this might work like in the following:
gender=("male") AND gender =("female") <= THIS DOES NOT WORK
I also tried out some other variants but can not figure out the right syntax.
Anyone can help me with this?
Best regards,
Daniel
=Max(Index(gender, 'male')) and Max(Index(gender, 'female'))
Or,
May be a bit simpler like: =Count(gender)>1
Hi Daniel,
This expression
=WildMatch('|' &Concat(Distinct gender,'|') & '|', '*male*') * WildMatch('|' &Concat(Distinct gender,'|') & '|', '*female*')
will return 1 only if
a/ 'male' and 'female' are selected
or
b/ No selections are made in the field 'gender', ie neither has been excluded.
If you only want to show your button when both field values male and female have been selected combine the expression with this one:
=if(GetSelectedCount(gender)>0,1,0) which will return 1 only if selections have been made.
Regards
Andrew
=Max(Index(gender, 'male')) and Max(Index(gender, 'female'))
Or,
May be a bit simpler like: =Count(gender)>1
Something like below,
=If(GetFieldSelections(gender,',')='female,male',1,0)
or Simply
=GetFieldSelections(gender,',')='female,male'
Hi Daniel,
A small but important correction to my post
The first expression should read
=WildMatch('|' &Concat(Distinct gender,'|') & '|', '*|male|*') * WildMatch('|' &Concat(Distinct gender,'|') & '|', '*|female|*')
Note the extra '|' characters around male and female. These are required because without them *male* would be a wildmatch even if only female was selected.
cheers
Andrew
May be try one of these:
=GetFieldSelections(gender) = 'female, male'
To make sure this is working, first check the order of male and female in a text box object using the GetFieldSelections(gender) after you select female and male are selected in gender list box. The order will be important here because female, male <> male, female.
HTH
Best,
Sunny
Dear QV community,
thank you for all the helpful replies. I tried out the solution of tresesco and it imidiately worked.
=Max(Index(gender, 'male')) and Max(Index(gender, 'female'))
Though, to be honest, i do not yet understand it 100%. I looked for the "index" function within the QV api (Automation Methods (?)) and could not find examples. So what does the index function do ( i guess it returns an array of values with 0 and 1(?) but why?)).
Cheers,
Daniel
Yes, index() returns array of 0s and 1s in this case. If the value (male/female) is found it returns 1 else 0. And the max() returns the maximum of them. I.e. - if the value is found max() returns 1 else 0 (out of all zeros). Hope this helps.