Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
PDurnall
Contributor II
Contributor II

Variable Setting wrong

I am building qlik app that builds QVDS for analysts to use however im getting a bit of a weird error im not sure how to resolve so i am using this bit of code to set the vTable to 'CostCentres'

PDurnall_0-1707219468211.png

but when stepping through it sets them as this below 

PDurnall_1-1707219525858.png

When I check the only time I use the RefC prefix is later in the code by around 2 sections

PDurnall_2-1707219581817.png

so I'm not sure how its setting the vTable to RefC when it hasn't even run that bit of code ?

 

Labels (2)
1 Solution

Accepted Solutions
henrikalmen
Specialist
Specialist

According to the middle image, vTable=CostCentres and that's what you set that variable to in the first image.

Line 6 in the first image probably sets vPrefix to (null) when it is executed, but maybe it isn't because of the if-statement that precedes it. Try using apostophes like this:
let vPrefix = '$(vTable)';

It is possible that vPrefix contains 'RefC' from a previous load.

Have you tried stepping through the script in debug mode to see what happens on each line?

View solution in original post

5 Replies
Anil_Babu_Samineni

@PDurnall Qlik capture the reload from top to bottom, It means when you find error in 8th line, but actually you already triggered till 7 lines, It means all the variables are stored into UI as script variable. 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
PDurnall
Contributor II
Contributor II
Author

so when I'm trying to de bug line by line its actually 7 lines ahead of its self .. then why is it setting my  prefix to 

[RefC name of column] instead of [CostCentres Name of column]

So that isn't a solution

 
PDurnall
Contributor II
Contributor II
Author

I have had to fix this instead by using 
LET vPrefix = 'CostCentres';

Instead of 
LET vPrefix = '$(vTable)';

 
henrikalmen
Specialist
Specialist

According to the middle image, vTable=CostCentres and that's what you set that variable to in the first image.

Line 6 in the first image probably sets vPrefix to (null) when it is executed, but maybe it isn't because of the if-statement that precedes it. Try using apostophes like this:
let vPrefix = '$(vTable)';

It is possible that vPrefix contains 'RefC' from a previous load.

Have you tried stepping through the script in debug mode to see what happens on each line?

PDurnall
Contributor II
Contributor II
Author

Yep when stepping through the code when it gets to line 6 on the first image it set the variable to RefC which isn't used for another 150-200 lines of code as image below Cost Centre is ran then future appointments and then RefC.

PDurnall_0-1707225423710.png

I added in the ' ' Around the Variable and this works  just really strange it grabs code from much later to use as the variable