Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

wgonzalez
Contributor

I'm getting "syntax error" with this code. What could be wrong?

I'm getting "syntax error" with this code.  What could be wrong?  It is related to the If..then.elseif block, since when I comment it the script works fine.

// Transformation of Attendance Transactions in HoursDetail

AttTrans:

LOAD DTPunchDate,
    
sType as TransType,
    
dblHours as AttHours,
    
id as EmpID,
    
sCompanyName as BusinessUnit,
    
left(sDeptName,index(sDeptName,'-')-1) as DeptNo,
    
Mid(sDeptName,Index(sDeptName,'-')+1) as DeptName,

     sJobTitleName as WorkCenter,
    
sEmployeeTypeName as PayGroup

FROM
C:\QlikViewDocuments\Extracts\TimeAide6\viewHoursDetail.qvd
(
qvd)
Where sEmployeeTypeName <> 'SEE';

/* ---- Joins Definition fields from TransDef ---- */

LET AttCategCode = '';

Left Join (AttTrans)

LOAD TransType,

//   nAttendaceCategory as AttCategory,

     if (nIsAbsent = 1,'Y','N') as AbsenceYN,
     
/* Takes out the "_" from the Parent transaction */
     
if (left(sParentCode,1)='_',Mid(sParentCode,Index(sParentCode,'_')+1),
     
sParentCode) as ParentTrans,
     
nAttendanceRevision as AttendanceRevision,
     
nTardinessRevision as TardinessRevision,

     
if nAttendaceCategory = 0 then
       
$(AttCategCode) = 'Payable'
      ELSEIF nAttendaceCategory = 1 then
       
$(AttCategCode) = 'Controllable
      ELSEIF nAttendaceCategory = 2 then
        $(AttCategCode) =  'NonControllable'
      ELSE
        $(AttCategCode) = 'Null'
      ENDIF
      $(AttCategCode) as AttCategory
Resident TransDef;
DROP Table TransDef;

//STORE AttTrans into $(vRoot)Transformations\TimeAide6\AttTrans.qvd;
//DROP Table AttTrans;

1 Solution

Accepted Solutions

Re: I'm getting "syntax error" with this code. What could be wrong?

Hi,

When it comes to fields, the syntax in the If() is different:

If(nAttendaceCategory = 0,
  'Payable',

  If(nAttendaceCategory = 1,
  'Controllable',
    If(nAttendaceCategory = 2,
      'NonControllable',
      'Null'))) AS AttCategory

Check the open / closed parentheses, I might be missing some.

Hope that helps.

Miguel

2 Replies

Re: I'm getting "syntax error" with this code. What could be wrong?

Hi,

When it comes to fields, the syntax in the If() is different:

If(nAttendaceCategory = 0,
  'Payable',

  If(nAttendaceCategory = 1,
  'Controllable',
    If(nAttendaceCategory = 2,
      'NonControllable',
      'Null'))) AS AttCategory

Check the open / closed parentheses, I might be missing some.

Hope that helps.

Miguel

wgonzalez
Contributor

Re: I'm getting "syntax error" with this code. What could be wrong?

It worked!  Thanks!