Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
saivina2920
Creator
Creator

How to make N/A if no attachment in the column field

I have the table data. In that, i have one column name called "Emp File(Attachment)".

Here i am listing some unnecessary link. For example, if i have some document it will be showing the document with entire path ==> //Server1/Files/Attach/EA10002.pdf

If document is not there then it will be showing as path ==> //Server1/Files/Attach/

What my client suggest is, if there no attachment in the like "//Server1/Files/Attach/" then it should show "N/A" else

it should list the document with the file ("//Server1/Files/Attach/EA10002.pdf")

How to change one particular column values as mentioned above.

below attached Qlikview report screenshot for your reference.

 

 

Labels (1)
2 Solutions

Accepted Solutions
Saravanan_Desingh

One solution is.

tab1:
LOAD EmpNo, Name, [Emp File(Attachment)] As [Emp File(Original)],
	If(Index(SubField([Emp File(Attachment)],'/',-1),'.'),[Emp File(Attachment)],'N/A')
	 As [Emp File(Attachment)];
LOAD * INLINE [
    EmpNo, Name, Emp File(Attachment)
    EA10001, A, //Server1/Files/Attach/
    EA10002, B, //Server1/Files/Attach/EA10002.pdf
    EA10003, C, //Server1/Files/Attach/
    EA10004, D, //Server1/Files/Attach/EA10004.pdf
    EA10005, E, //Server1/Files/Attach/
];

View solution in original post

saivina2920
Creator
Creator
Author

below is the correct query for ms sql server.

SELECT EmpNo, Name,Department,
[Emp File(Attachment)] as EmpFileAttachmentOriginal,
CASE WHEN LEN([Emp File(Attachment)])>LEN('//Server1/Files/Attach/') THEN [Emp File(Attachment)] ELSE 'N/A' END As [EmpFileAttachmentNew]
from Emp_table

View solution in original post

4 Replies
Saravanan_Desingh

One solution is.

tab1:
LOAD EmpNo, Name, [Emp File(Attachment)] As [Emp File(Original)],
	If(Index(SubField([Emp File(Attachment)],'/',-1),'.'),[Emp File(Attachment)],'N/A')
	 As [Emp File(Attachment)];
LOAD * INLINE [
    EmpNo, Name, Emp File(Attachment)
    EA10001, A, //Server1/Files/Attach/
    EA10002, B, //Server1/Files/Attach/EA10002.pdf
    EA10003, C, //Server1/Files/Attach/
    EA10004, D, //Server1/Files/Attach/EA10004.pdf
    EA10005, E, //Server1/Files/Attach/
];
Saravanan_Desingh

Output.

commQV62.PNG

saivina2920
Creator
Creator
Author

I am getting error "Incorrect syntax near the keyword 'If' while i am executing in SQL server.

OleDb error

Connector reply error: ErrorSource: Microsoft OLE DB Provider for SQL Server, ErrorMsg: Incorrect syntax near the keyword 'If'.

SQL SELECT EmpNo, Name, [EmpFile(Attachment)] As [EmpFile(Original)],
EmpFile(Attachment) as EmpFileAttachmentOriginal,
If(Index(SubField([EmpFile(Attachment)],'/',-1),'.'),[EmpFile(Attachment)],'N/A') As [EmpFileAttachmentNew],
Department from Emp_table;

 

saivina2920
Creator
Creator
Author

below is the correct query for ms sql server.

SELECT EmpNo, Name,Department,
[Emp File(Attachment)] as EmpFileAttachmentOriginal,
CASE WHEN LEN([Emp File(Attachment)])>LEN('//Server1/Files/Attach/') THEN [Emp File(Attachment)] ELSE 'N/A' END As [EmpFileAttachmentNew]
from Emp_table