Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Can someone help me with syntax. There's something wrong here, but I don't know what it is:
LET vLastWeekLastYr = 52;
LET vCurrentWeekThisYr = 53;
If(
$(vCurrentWeekThisYr) > $(vLastWeekLastYr),
LET vCurrentWeek = $(vLastWeekLastYr),
LET vCurrentWeek = $(vCurrentWeekThisYr)
);
Script IF statements work differently than expression IF statments. Try this:
LET vLastWeekLastYr = 52;
LET vCurrentWeekThisYr = 53;
IF $(vCurrentWeekThisYr) > $(vLastWeekLastYr) THEN
LET vCurrentWeek = $(vLastWeekLastYr);
ELSE
LET vCurrentWeek = $(vCurrentWeekThisYr);
ENDIF
Script IF statements work differently than expression IF statments. Try this:
LET vLastWeekLastYr = 52;
LET vCurrentWeekThisYr = 53;
IF $(vCurrentWeekThisYr) > $(vLastWeekLastYr) THEN
LET vCurrentWeek = $(vLastWeekLastYr);
ELSE
LET vCurrentWeek = $(vCurrentWeekThisYr);
ENDIF
This works too:
LET vLastWeekLastYr = 52;
LET vCurrentWeekThisYr = 53;
LET vCurrentWeek = If(vCurrentWeekThisYr > vLastWeekLastYr, $(vLastWeekLastYr), $(vCurrentWeekThisYr));
Thank you Aaron! 🙂
Hi
There are two different if-statements.
One that's used inside a load-statement (and that's the one you are using), and another one that's used as a control statement (this is the one you should be using). The syntax is as follows:
if $(vCurrentWeekThisYr) > $(vLastWeekLastYr) then
LET vCurrentWeek = $(vLastWeekLastYr)
else
LET vCurrentWeek = $(vCurrentWeekThisYr)
end if
Look in the QV help for more examples.
/Fredrik