I have a very simple document that works fine in qlikview desktop. It refreshes in 2 seconds but when refreshed in distribution service it never ends keeping the qvb.exe process at 100% cpu until ended by hand.
I found the problem to be the use of a variable in the formula of other variable. The exact code that hangs is:
set yr_amnt = if (year(SAL_DATE) = year($1) AND BEFORE_AFTER = 0, SAL_AMOUNT);
set mo_amnt = if (month(SAL_DATE) = month($1) and day(SAL_DATE) <= day($1), $(yr_amnt($1)));
Note that mo_amnt uses yr_amnt in the formula.
Then I changed the second variable to this:
set mo_amnt = if (month(SAL_DATE) = month($1) and
day(SAL_DATE) <= day($1) and
year(SAL_DATE) = year($1) and
BEFORE_AFTER = 0, SAL_AMOUNT);
Functionally equivalent, but is not using the first variable. This time the job finished in 2 seconds.
It looks like qlikview districution service runs in a infinite loop when evaluating variables inside other variables.....