Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
wgonzalez
Partner - Creator
Partner - Creator

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
Miguel_Angel_Baeyens

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

View solution in original post

2 Replies
Miguel_Angel_Baeyens

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
Partner - Creator
Partner - Creator
Author

It worked!  Thanks!