Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Qlik Cloud Maintenance is scheduled between March 27-30. Visit Qlik Cloud Status page for more details.
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 Replies
Joseph_Musekura
Support
Support

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

/joseph

marcus_sommer
MVP & Luminary
MVP & Luminary

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