Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Scripting If Statement / Case Statement

All

I'm having issues using the If statement on the scripting back end of QlikView

Can somebody explain why this doesn't work?

If Left([Insurer Policy Number],7) = 'GSPC701' Then 'Skippy'

Else 'Sampras'

End If as [Test],

Thanks in advance

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Have you tried this?

Load *,

     If ( Left([Insurer Policy Number],7) = 'GSPC701' ,'Skippy' ,'Sampras' ) as  Test ;


SQL SELECT

*

FROM SkippyReporting.dbo.Core_Product_All_Txns;

View solution in original post

13 Replies
Anonymous
Not applicable
Author

James

Your syntax for a QlikView script was adrift, try something like this:

     If ( Left([Insurer Policy Number],7) = 'GSPC701' ,'Skippy' ,'Sampras' ) as [Test] ,

Best Regards,     Bill

israrkhan
Specialist II
Specialist II

Only this part.

If Left([Insurer Policy Number],7) = 'GSPC701' , 'Skippy', 'Sampras') as [Test]

That is SQL Case Statment Syntax...

Not applicable
Author

I am putting this in a SQL selectstatement. But it doesn’t work (see below)

  

SQL SELECT
 

   If ( Left([Insurer Policy Number],7) = 'GSPC701','Skippy' ,'Sampras' ) as [Test] ,
       *

FROM SkippyReporting.dbo.Core_Product_All_Txns;

Anonymous
Not applicable
Author

James

Ahh, I misunderstood you I thought you were talking about a QV Load Script statement.

What brand of database are you trying to do this SQL query against ?

Best Regards,     Bill

CELAMBARASAN
Partner - Champion
Partner - Champion

You cannot use Qlikview expression in sql statement rather you can use it on preceding load.


try this

Load *,

     If ( Left([Insurer Policy Number],7) = 'GSPC701','Skippy' ,'Sampras' ) as [Test];

SQL SELECT

       *
FROM SkippyReporting.dbo.Core_Product_All_Txns;

Not applicable
Author

Apologies

it is a QV load script. this is the entie script below.

ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='£#,##0.00;-£#,##0.00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';



ODBC CONNECT TO lassie (XUserId is GaLDOJdJDaSYFVFMNLZGHXUNBbaKGYVMBbYKWdA);



SQL SELECT 

     If ( Left([Insurer Policy Number],7) = 'GSPC701' ,'Skippy' ,'Sampras' ) as [Test] ,
*

FROM SkippyReporting.dbo.Core_Product_All_Txns;

Not applicable
Author

HI

I just tried this to no avail.

ThousandSep=',';
SET DecimalSep='.';
SET MoneyThousandSep=',';
SET MoneyDecimalSep='.';
SET MoneyFormat='£#,##0.00;-£#,##0.00';
SET TimeFormat='hh:mm:ss';
SET DateFormat='DD/MM/YYYY';
SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

Load
*,
    
If ( Left([Insurer Policy Number],7) = 'GSPC701','Skippy' ,'Sampras' ) as [Test]
     ;
ODBC CONNECT TO lassie (XUserId is GaLDOJdJDaSYFVFMNLZGHXUNBbaKGYVMBbYKWdA);
SQL SELECT

     *
FROM SkippyReporting.dbo.Core_Product_All_Txns;



CELAMBARASAN
Partner - Champion
Partner - Champion

Qlikview execute the statement after the SQL word in the database only not within qlikview, so qlikview expressions cannot used there.

Not applicable
Author

Can you suggest a solution?

Thanks for your help