Qlik Community

Ask a Question

New to QlikView

If you’re new to QlikView, start with this Discussion Board and get up-to-speed quickly.

Announcements
Qlik Highlights 2020 Giveaway! Watch, reply and have a chance to win a $200 Amazon Gift Card! Watch Video
cancel
Showing results for 
Search instead for 
Did you mean: 
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

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

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";

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

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.

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

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? 

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]

Creator II
Creator II

Thank you.  This is helpful.