Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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'.
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";
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";
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
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";
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]
Thank you. This is helpful.