Discussion Board for collaboration related to Qlik Education.
I am having problems to have string concatenation in an if statement in a load script SQL statement.
Select IF(Month(`TxDate`) < 8, 'Season ' + Year(`TxDate`), 'Season ' + (Year(`TxDate`)+1)) AS Season
Can anyone explain what I am doing wrong?
If() not is sintax SQL, is sintax QV.
case When ... then
But Month Sintax depending on Your DB.
You can use Preceding Load :
If(Month(...),........) as Season;
SQL Select *
Thanks for your reply.
However the If statement is not the issue as it is working fine. It is the concatenation which is working not as expected.
('Season ' & (Year(`TxDate`)-1) & '-' & (Year(`TxDate`))
is resulting in 0.
I am sure that Year works fine as I tried it as a separate expression. I am afraid that & is being interpreted as a logical AND expression.
Btw - I am using MySQL but this is not the issue.
Ok, MySql has If() Sintax.
Tray to remove ' in Year('TxDate') -> Year(TxDate)
Just to be sure, try replacing the &'-'& with &'_'& or some other separator.
I solved this issue with a preceding load as follows:
IF(Month(`TxDate`) < 8, 'Season ' + Year(`TxDate`), 'Season ' + (Year(`TxDate`)+1)) AS Season;