Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Can anyone tell me how to use Field value as Variable Name and return the Variable Value in Table? The scenario is a little bit complicated. A case is provided to explain as below, hope it could help. Thanks!
1. A source table with below structure is loaded into Qlikview:
user_id | kpi_id | Item Desc | Item | VariableName | Default Value |
---|---|---|---|---|---|
A | 1 | Notification | ntf | vK1_ntf | ON |
A | 1 | Notification Time Interval | ntf_int | vK1_ntf_int | 30 |
A | 2 | Notification | ntf | vK2_ntf | OFF |
A | 2 | Notification Time Interval | ntf_int | vK2_ntf_int | 60 |
2. In Variable Overview, below 4 variables are created:
vK1_ntf
vK1_ntf_int
vK2_ntf
vK2_ntf_int
- The above 4 variable names are same as the [VariableName] in the source table.
- The initial value of the above 4 variables are assigned according to the [Default Value] in the source table.
Variable Name | Value |
---|---|
vK1_ntf | ON |
vK1_ntf_int | 30 |
vK2_ntf | OFF |
vK2_ntf_int | 60 |
Now,
the value of these 4 variables are allowed to modified on the interface (By Input Box Object). In order to compare the [Default Value] / [New Value] of variables and exporting this table to external, a table is created and the expected result is shown as below:
user_id | kpi_id | Item Desc | Item | VariableName | Default Value | New Value | Idea to get [New Value] | |
---|---|---|---|---|---|---|---|---|
A | 1 | Notification | ntf | vK1_ntf | ON | OFF | $(vK1_ntf) | |
A | 1 | Notification Time Interval | ntf_int | vK1_ntf_int | 30 | 60 | $(vK1_ntf_int) | |
A | 2 | Notification | ntf | vK2_ntf | OFF | ON | $(vK2_ntf) | |
A | 2 | Notification Time Interval | ntf_int | vK2_ntf_int | 60 | 90 | $(vK2_ntf_int) |
My idea is to call those variables in the Expressions of the Table for each row based on the [VariableName] such that [New Value] can be returned.
However, I have no idea how to use [VariableName] to call the variables. Or can the field value ([VariableName]) be used as individual variable name and return its value?
The above scenario is also attached in QVW. Some of the method are tried but all are unexpected result. Hope if anyone can help me. Thanks in advance!
T.NG
You can use peek() function in script to calculate the variables but i doubt that it can be populated as different row values for a field. You need to implement some logic as expression and define the colum
Few questions from my side :
how you are getting the newvalue??
The new values can be modified by users on the interface (Input Box). These new value will then be displayed on pivot/straight table. By exporting this table and doing some transformation, these new values will be returned as default value next time.
What is the definition of this new variable column
'
Peek() should not be the case. I have already create those variables and assign the values in script, but i can't return the variable value on dashboard.
I think the only way to represent this can be the inpursum() function in the straight table.
Follow these threads
There is no new variable. Some variables have been created with default values. However, the value of these variables could be changed on the interface. A table is therefore required to show the old and new value.
If this table is rather static with respect to number of variables to show, you can try a pick / match combination as expression, something like
=pick( match( VariableName, 'VK1_ntf','VK1_ntf_int','VK2_ntf','VK2_ntf_int'),
$(VK1_ntf),
$(VK1_ntf_int),
$(VK2_ntf),
$(VK2_ntf_int)
)
You need wrap around with =$(), see below:
Exp1 : =$(=$(vKPI)&$(vItem))
Exp2: =$(=$(vDynamicVariable))
Hope this was helpful or answered your question
Thanks,
Angad