Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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;
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
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
It worked! Thanks!