Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

If Statement

Hi Guys,

I am getting the below error while using the if statement. Please help me out.

select Age,

    Alias,

    City,

    if (City = 'texas','tx',city) as [newcity],

    Finisher,

    Married,

    Name,

    Notority_Level,

    wwechampion

FROM master.dbo."t_wrestlersinfo";

SQL##f - SqlState: 37000, ErrorCode: 156, ErrorMsg: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'if'.

1 Solution

Accepted Solutions
Highlighted

QlikView is fully case sensitive, field names and the data is case sensitive. So city does not exist in your data but City does.

You have also mixed QlikView syntax and SQL syntax. You need to separate the SQL part of the script and the QlikView part.

Try this

Load *,

         if (City = 'texas','tx',City) as [newcity] ;

Sql select Age,

    Alias,

    City,

    Finisher,

    Married,

    Name,

    Notority_Level,

    wwechampion

FROM master.dbo."t_wrestlersinfo";

View solution in original post

7 Replies
Highlighted

Try this:

Table:

LOAD *,

          If(City = 'texas', 'tx', city) as [newcity];

select Age,

    Alias,

    City,

    Finisher,

    Married,

    Name,

    Notority_Level,

    wwechampion

FROM master.dbo."t_wrestlersinfo";

Highlighted
Not applicable

Hi,

As sunny mentioned but small change, else part should be "City"

Table:

LOAD *,

          If(City = 'texas', 'tx', City) as [newcity];

select Age,

    Alias,

    City,

    Finisher,

    Married,

    Name,

    Notority_Level,

    wwechampion

FROM master.dbo."t_wrestlersinfo";


--Uva

Highlighted
Not applicable

Now i am getting this error

Cannot open file 'C:\Users\hi\Desktop\master.dbo."t_wrestlersinfo"' The system cannot find the file specified.

Highlighted

QlikView is fully case sensitive, field names and the data is case sensitive. So city does not exist in your data but City does.

You have also mixed QlikView syntax and SQL syntax. You need to separate the SQL part of the script and the QlikView part.

Try this

Load *,

         if (City = 'texas','tx',City) as [newcity] ;

Sql select Age,

    Alias,

    City,

    Finisher,

    Married,

    Name,

    Notority_Level,

    wwechampion

FROM master.dbo."t_wrestlersinfo";

View solution in original post

Highlighted
Creator II
Creator II

I have a similar question.  I'm using this If statement --

If ([seriesid] = ' x', [value]) as [Alabama] ,

I'm trying to replace [value] with [Alabama] for all records with [seriesid] = x.  Is this the correct If statement? 

Highlighted

Hi Jessica, you need to use something like this

     If([seriesid] = 'x', 'Alabama',  [value]) as [value]

Remember Qlik is case sensitive so you may need to test  

          if(lower([seriesid]) = 'x',  'Alabama',  [value]) as [value]

Highlighted
Creator II
Creator II

Thank you.  This is helpful.