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

SET VARIABLE AND IF STATEMENT IN LOAD SCRIPT

Hi all,

I'm trying to understand how to use un IF statement on a calculated ratio in the script editor. I have a table with two numeric fields/two measures, "[Pv One]" and "[Valore PV New]", and I know how to do a "flag variable" on their ratio in a pivot table (i.e. create an expression in this way -->

_nappi_1-1643630376004.png)

 

but I'm not be able to recreate this such of flag variable in the script editor. I thought to create first the ratio variable with a LET and then insert the IF statement within the load script of the table to create the flag variable -->

 

_nappi_2-1643631042518.png

 

I have this error:

 

_nappi_3-1643631068506.png

 

How should the script be modified to achieve this?

 

Thank you deeply

 

 

Labels (5)
2 Solutions

Accepted Solutions
Joseph_Musekura
Support
Support

In the IF statement, did you try to use $(pv_ratio) instead of pv_ratio ?

/joseph

View solution in original post

marcus_sommer

Your variable needs to be created with SET instead of LET because LET evaluated the content immediately and assigned just this result to the variable and did not contain the string. Like already mentioned you should use a $-sign expansion by calling the variable, like $(pv_ratio) to avoid that Qlik interpretes it as a field.

- Marcus

View solution in original post

2 Replies
Joseph_Musekura
Support
Support

In the IF statement, did you try to use $(pv_ratio) instead of pv_ratio ?

/joseph

marcus_sommer

Your variable needs to be created with SET instead of LET because LET evaluated the content immediately and assigned just this result to the variable and did not contain the string. Like already mentioned you should use a $-sign expansion by calling the variable, like $(pv_ratio) to avoid that Qlik interpretes it as a field.

- Marcus