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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Frédéricdh
Creator II
Creator II

Variable

I define a variable like that BREF =GetFieldSelections(XBREFNUM)

 

and in the script I define like that XBREFNUM = $(BREF) 

 

but when i start a load from the script, the prog says i have an error because XBREFNUM = GetFieldSelections(XBREFNUM)

 

That why in the script i wrote a condition on $(BREF)  but it doesn't work

Labels (1)
3 Replies
TauseefKhan
Creator III
Creator III

Hi @Frédéricdh 

The GetFieldSelections() function is used in the UI part of Qlik Sense to retrieve the current selections of a field as a string. It cannot be used directly in the data load script because the script does not interact with the UI selections.

If you want to use the value of a field selection within the script, you need to pass it as a parameter when the script is reloaded, which is typically done through an action in the UI, not directly in the script.

Define the variable:

SET BREF = 'YourStaticValue'; // Assigns a static value to BREF
LET BREF = Peek('FieldName', 0, 'TableName'); // Assigns the result of an expression to BREF

Use the variable in the script:

LOAD
Field1,
Field2,
$(BREF) as XBREFNUM
FROM DataSource;

***Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.***

Frédéricdh
Creator II
Creator II
Author

But, I want to use the value of XBREFNUM, which is selected from the user. That's why I use GetFieldSelections

Frédéricdh
Creator II
Creator II
Author

I make an If statement in my script to overcome the problem, like that

 

If $(BREF) = '= GetFieldSelections(XBREFNUM)' then

 

but than I have this error message

Syntax error

Unexpected token: '=', expected one of: '(', 'Yellow', 'ZTestw_z', 'OPERATOR_PLUS', 'OPERATOR_MINUS', 'not', 'bitnot', ...

If >>>>>>=<<<<<< GetFieldSelections(XBREFNUM) = '= GetFieldSelections(XBREFNUM)' then

 

I don't see how to overcome the problem.