Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If Len Fuction

Hi All

I would like to write an "If" statement that checks the number of characters in a field then return "N/A" if the field contains more than 15 characters, otherwise return the value

I tried this but it doesn't work:

If(Len(GUID>15,'N/A',GUID)) as GUID

1 Solution

Accepted Solutions
Not applicable
Author

Hi Tumelo,

you have brackets in the wrong place, you need to close the Len

If(Len(GUID)>15,'N/A',GUID) as GUID

hope that helps

Joe

View solution in original post

9 Replies
Not applicable
Author

Hi Tumelo,

you have brackets in the wrong place, you need to close the Len

If(Len(GUID)>15,'N/A',GUID) as GUID

hope that helps

Joe

yduval75
Partner - Creator III
Partner - Creator III

Hello,

If(Len(GUID)>15,'N/A',GUID) as GUID

anbu1984
Master III
Master III

If(Len(GUID)>15,'N/A',GUID) as GUID


Not applicable
Author

hi Tumelo,

i think expression looks wrong, try the below:

If(Len(GUID)>15,'N/A',GUID) as GUID

Not applicable
Author

Thanks guys!

Not applicable
Author

And how do I include another If condition to say If the field GUID is NULL it must also return "N/A" ?

anbu1984
Master III
Master III

If(Len(GUID)>15 0r Len(Trim(GUID)) = 0,'N/A',GUID) as GUID

0r

If(Len(GUID)>15 0r Len(Trim(GUID)) = 0,'N/A',GUID) as GUID

Note: I was unable to post with "0r" in above condition. Replace number zero by o in above expressions

tombombadil
Contributor III
Contributor III

Just keep in mind, it's also possible to nest if statements:

If (Len(GUID), 'N/A', if(Len(GUID)>15, 'N/A', GUID)) as GUID

But of course, for this specific problem, anbu's solution looks better

Not applicable
Author

Thanks guys! again