Categories
Common QlikView /en QlikView Workarounds /en Script /en Tips n Tricks /en

QlikView Generate Dynamic Variables

Sometimes it could be very usefull to generate variable dynamicaly, in QlikView you can do this easily with a trick inside the load statement of you application!
Here is a short example (will give you some examples for a smart usage later):

TRACE --- LOAD ACTION AND EVENT ---;

VariableTable:
LOAD DISTINCT 
	 tblActionType.ActionType AS VariableName 
FROM
[..\04 DataMart\MMACTIONS.qvd]
(qvd)
WHERE Match( tblActionType.ActionType,'UnitMovein')>0;

TRACE --- Generate variables for each ActionType ---;

//Get the number of available rows 
LET NoVariable = NoOfRows('VariableTable');

TRACE Number of Dynamic Vars: $(NoVariable);

//Lets build the dynamic variables
FOR DatenbankIter = 0 TO $(NoVariable) - 1

	LET curVariableName = peek('VariableName',DatenbankIter,'VariableTable');
	LET $(curVariableName)= peek('VariableName',DatenbankIter,'VariableTable');

NEXT

//jetzt entferne ich die Variablentabelle wieder
DROP TABLE VariableTable;

Leave a Reply