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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problems with Conditional Function IF

Hi,

I want to use the If function, but when I reload the script it appears a message that says Script line error:
if(num(month(today())) = 1)

The script is the following:

if(num(month(today())) = 1)
//si es enero, considero el cambio de año como un caso particular
//genera el QVD correspondiente a diciembre del año pasado
Año = year(today()) - 1;

Transacciones_ACA_Sum:
NOCONCATENATE
LOAD
FFECHA,
SKU,
NODO,
Sum(CAJAS) as CAJAS,
Sum(NIV) as NIV,
Sum(KILOS) as KILOS
RESIDENT Transacciones_TPM
WHERE YEAR(FFECHA) = $(Año) AND MONTH(FFECHA) = 12
GROUP BY
FFECHA,
SKU,
NODO;

STORE Transacciones_ACA_Sum INTO $(vPathBase)\QVD\Transacciones_ACA_Sum\Transacciones_ACA_Sum_$(Año)_12.QVD;
DROP TABLE Transacciones_ACA_Sum;

I thing I´m writing bad the If condition, what do you think?

Thanks,

Francisco

3 Replies
Not applicable
Author

Maybe you just forgot the "then" and end if

Try this

if(num(month(today))=1) then

youre code

end if

Not applicable
Author

the syntax for if is :

IF( condition, value_if_condition_is_true, value_if_condition_is_false)

IF(0=1, 'dog', 'cat') is 'cat'

it works like the ternary operator "?" in C

Not applicable
Author

Thanks, I tried to do that, but appears the following message:

Script line error:
if(num(month(today())) = 1)

Unknown statement
then
Año = year(today()) - 1

Thanks

Francisco