Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create Variable Field

Hi all,

I have the following problem I cannot solve:

I want to create a Field with variable entries.

Eg: After some selections Field a has the possible Values X, Y and Z. Now I want Field B to contain exactly these three values.

Field A
Z
Y
X
V (not possible Value)

W (np)

etc. (np)

Field B
Z
Y
X

What I tried:

Create a variable:      vCon = concat(Distinct [Field A],'/')

Script:                        Load subfield($(vCon),'/') as [Field B]

But I get an error message when loading the script:

Error in expression:

')' expected

If I try without a variable it works, so i belive the error lies there.

Load subfield('Z/Y/X','/') as [TestField B]

Hope someone can help, thank you in advance

Best regards

5 Replies
petter
Partner - Champion III
Partner - Champion III

The variable vCon has to be calculated in the UI ... It is not obvious from your question where it is created ...?

1) In the UI as a create via some menu command?

2) As a line in the Load Script?

Not applicable
Author

Thanks for your response!

It is created in the UI (settings>variable overview>add)

petter
Partner - Champion III
Partner - Champion III

Two things that seem a bit odd:

1) Why is there no single quotation marks on each side of the $(vCon):

       Load subfield($(vCon),'/') as [Field B]

The error message shows single quotation marks - how did they get into the error message.

2) Why are you using the two parameter version of SubField and not the three parameter version?

    The two parameter version will generate one row for each of the values in the vCon - is that what you want?

    The three parameter version picks out a specific subfield from the string.

Anyhow I think:

     Load SubField(  '$(vCon)' , '/' ) AS [Field B] .....

should be more correct with regards to the quotation marks.

You don't show the entire load statement either - could you do that - with the FROM or RESIDENT clause?

Not applicable
Author

Yes, as I tried to show above I would like to generate one row for each of the values.

If do it as you suggest, I get as a result

Field B

= concat(Distinct [Field A],'

')

So the quotation marks somehow prevent the variable to be calculated.

petter
Partner - Champion III
Partner - Champion III

If it is possible for you to share your application or a smaller sample of it to illustrate the problem as a QVW and upload it - it would be much easier to help you...