# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

## Formulas with two alternate states

Hello Guys,

I have these formulas, where the field "OPTIONAL" comes from a different alternate state called "State10"

=Chr(39)&Replace(GetFieldSelections(OPTIONAL,',', GetSelectedCount(OPTIONAL)), ',' , chr(39)&','&chr(39)) &chr(39)

how do I add the alternative state to this formula???

Tags (2)
1 Solution

Accepted Solutions
Contributor III

## Re: Formulas with two alternate states

Try:

=if(count({1} OPTIONAL) = count({State10} OPTIONAL),'blank',    replace( '#'&Concat({State10} OPTIONAL,'#,#')&'#','#',chr(39)))

9 Replies
Not applicable

## Re: Formulas with two alternate states

state_name::field_name

Not applicable

## Re: Formulas with two alternate states

If I go like this:

=Chr(39)&Replace(GetFieldSelections(State10:PTIONAL,',', GetSelectedCount(State10:PTIONAL)), ',' , chr(39)&','&chr(39)) &chr(39)

The expression appears to be wrong, what should I do?

Not applicable

## Re: Formulas with two alternate states

Try this:

=Chr(39)&Replace(GetFieldSelections([State10]:PTIONAL,',', GetSelectedCount([State10]:PTIONAL)), ',' , chr(39)&','&chr(39)) &chr(39)

Don't worry if it's not parsing, it just happens sometimes with set analysis

Not applicable

## Re: Formulas with two alternate states

Tried with the error but ended up still not working.

Contributor III

## Re: Formulas with two alternate states

Hi, i don't think you can use the state::field syntax with this system function, have you tried something like

=replace( '#'&Concat({State10} OPTIONAL,'#,#')&'#','#',chr(39))

Thanks

Steve

Luminary

## Re: Formulas with two alternate states

You can't use set analysis with the GetFieldSelections() function. Use an embedded Only function instead e.g.:

GetFieldSelections(Only({State10} OPTIONAL)) etc...

Not applicable

## Re: Formulas with two alternate states

It worked perfectly buddy, however, the list starts with all OPTIONALS selected, and I need that to start 'blank', with no selections at the beginning.

Is that possible?

Contributor III

## Re: Formulas with two alternate states

Try:

=if(count({1} OPTIONAL) = count({State10} OPTIONAL),'blank',    replace( '#'&Concat({State10} OPTIONAL,'#,#')&'#','#',chr(39)))

Not applicable

## Re: Formulas with two alternate states

Thank you so much. Worked perfectly.