Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table TABLE1 with two columns, COLUMN1 and COLUMN2
COLUMN1 | COLUMN2 |
---|---|
RED | 10 |
GREEN | 0 |
BLUE | 0 |
PURPLE | 0 |
I am setting a variable in the script as below:
Let vStatus = Peek("COLUMN1",0,TABLE1);
I am trying to use this variable in text box background color as a calculated color as below
if(vStatus>>0,Red(),Green())
I always get green background for the text box. I tried hardcode value 10 in the let statement and that changes the color to Red. So somehow the Let statement with peek is not working. Need some advice and help!
Thanks!
You can use peek outside a Load statement, but you need to specify the field name and the table name with single quotes:
Let vStatus = Peek('COLUMN1',0,'TABLE1');
This Let statement will assign the text 'RED' to the variable vStatus, butI am not sure I understand how you want to use it...
If you want to specify the color based on the value in field COLUMN2 - i.e. different colors in different lines of a table - then you should use the following color expression:
if(COLUMN2>0,Red(),Green())
or if you consider the possiblity of COLUMN2 having several possible values:
if(count(distinct COLUMN2)=1,
if(COLUMN2>0,Red(),Green()),
lightgray() )
HIC
You cann't use peek outside LOAD statement(below).
Use this function:
FieldValue(fieldname , n )
Returns the field value found in position n of the field fieldname (by load order). fieldname must be given as a string value, e.g. the field name must be enclosed by single quotes. The first field value is returned for n=1. If n is larger than the number of field values, NULL is returned.
You can use peek outside a Load statement, but you need to specify the field name and the table name with single quotes:
Let vStatus = Peek('COLUMN1',0,'TABLE1');
This Let statement will assign the text 'RED' to the variable vStatus, butI am not sure I understand how you want to use it...
If you want to specify the color based on the value in field COLUMN2 - i.e. different colors in different lines of a table - then you should use the following color expression:
if(COLUMN2>0,Red(),Green())
or if you consider the possiblity of COLUMN2 having several possible values:
if(count(distinct COLUMN2)=1,
if(COLUMN2>0,Red(),Green()),
lightgray() )
HIC
Hi, Henric
Thanks, will keep in mind (Peek).
Hi ,
Please check the Qlikview Reference manual for help on Peek() function. And it's clearly mentioned that peek() can be used outside the LOAD statement but with the TABLE name reference. The peek function searches for the Tables in the Qlikview database(which are already loaded in the qvw file). Peek() function syntax is wrong in your situation.
As suggested by Henric you can make use of the column in the table for changing the color based on value in the field rather than making use of variable.
- Sri