Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SELECT is activated once

Hi,

I am trying to loop through Areas, Branches and their values, but it seems the select statement is activated only once, and afterwards the selected value remains the same, even after using the clear method.

What am I doing wrong?

thnx in advance.

sub calculateAreasGoals
dim a(5)
Set val=ActiveDocument.Fields("Areas").GetPossibleValues
'ActiveDocument.ClearAll False
For i=0 to val.Count-1
ActiveDocument.Fields("Areas").Select val.Item(i).Text
a(i) = loopBranches
'Activedocument.ClearAll
next 'i
set val=nothing
Activedocument.Fields("Areas").Clear
ActiveDocument.ClearAll False
end sub

function getGoal()
set val_1 = nothing
Activedocument.Fields("NISGOAL").clear
Set val_1=ActiveDocument.Fields("NISGOAL").GetPossibleValues
ActiveDocument.Fields("NISGOAL").Select val_1.Item(0).Text
Activedocument.Fields("NISGOAL").Unlock
Activedocument.Fields("NISGOAL").Clear
tmp = val_1.Item(0).Text
set val_1 = nothing
getGoal = tmp
end function

function loopBranches
Set branch=ActiveDocument.Fields("BRANCHNAME").GetPossibleValues
Accumulator=0
for i = 0 to branch.Count-1
set vals=nothing
tmp = branch.Item(i).Text
ActiveDocument.Fields("BRANCHNAME").Unlock
ActiveDocument.Fields("BRANCHNAME").Clear
ActiveDocument.Fields("BRANCHNAME").Select branch.Item(i).Text
set vals=ActiveDocument.Fields("BRANCHNAME").GetSelectedValues
Accumulator=Accumulator+getGoal
ActiveDocument.Fields("BRANCHNAME").Clear
next 'i
set branch=nothing
ActiveDocument.Fields("BRANCHNAME").Unlock
ActiveDocument.Fields("BRANCHNAME").Clear
loopBranches = Accumulator
end function

Labels (1)
0 Replies