Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there any way to get the variable value, which is built in front-end when the app loading is over?
Imagine in your app front-end you have a variable containing a complicated formula showing some numbers as a result.
This formula can be built only in front-end (because it is a result of data load & transformation, so in order to build this variable in script you need to bring together lot of tables which is insane).
It seems like such variable gets the value only when the app is opened, isn't it?
All means trying to get that value in script result in variable definition (the formula itself) or null value.
The only thing really working well is using an inputbox (such results can be easily picked up in the script and stored into qvd). From the 1st point of view a variable set with '=' sign should not be evaluated (using $() ) and thus seems to operate in the same way as a variable defined by an inputbox. But the problem is - the inputbox does not have any definition (the definition happens via the manual typing), while a non-inputbox variable contains a definition formula (like =sum(myField) ), which must be evaluated while opening a sheet (even though this variable is defined with '=' sign).
Any suggestions?
If I understand you correctly, you want to evaluate the expression from a variable and store the result in a QVD? In script? If the expression uses data from multiple tables, I don't think there is any way to evaluate the expression in the load script except by making required table associations. See https://qlikviewcookbook.com/2020/03/creating-temporary-script-associations/ for suggestions.
-Rob
AFAIK there is no way to get the result from an expression within a variable because this result is only calculated while the UI exists. Otherwise it's just a stored definition.
A workaround in QlikView for such scenarios could be to use 2 different variables for each case, like:
Var: = sum(Field)
Var.v:
and Var.v is filled per macro triggered per button or by selecting/changing fields/variables. There are various ways to implement such logic and a quite simple one is to use an input-box and looping through it for all wanted ones, like:
sub TransferVariableValuesFromCalculatedVariablesToFixedVariables
set table = ActiveDocument.GetSheetObject( "IB03" )
for RowIter = 0 to table.GetRowCount-1
for ColIter =0 to table.GetColumnCount-1
set cell = table.GetCell(RowIter,ColIter)
if ColIter = 0 then
vVariable = cell.Text & ".v"
end if
if ColIter = 2 then
vVariableValue = cell.Text
end if
next
set v = ActiveDocument.Variables(vVariable)
v.SetContent vVariableValue, true
next
end sub
If the variable-results are displayed within any object it might be also exported to any file or by using any write-back logic stored within a data-base.
@rwunderlich : yes, this is exactly what I want (to evaluate the expression from a variable containing expression which uses data from multiple tables and store the result in a QVD in script. This is what I also thought about, but it is quite a pain to do that in script because the complexity of the expression (there are also several of them in different apps).
@marcus_sommer : interesting idea, but I am in QSEoW.
I hope Automations could help to solve this (an automation opening the app, getting the result of the front-end variable and storing it into a QVD). I need try that out.
THANK YOU both for your suggestions. Very much appreciated!