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

Checking Length of a Field

Good morning all.

Quick question for you all. Am I able to check the exact length of a field in a table like this? If not, can someone suggest a better way.

Thanks
Thom

if (len([finalCalledPartyNumber] = 11),
Num(Right([finalCalledPartyNumber] ,10)),'0000000000') as [Final Called Number],
if (len([finalCalledPartyNumber] = 4),
Num(Right([finalCalledPartyNumber] ,4)),'0000') as [Final VoIP Called Number],
if (len([finalCalledPartyNumber] = 3),
Num(Right([finalCalledPartyNumber],3)),'000') as [Final Common Called Number],

3 Replies
maneshkhottcpl
Partner - Creator III
Partner - Creator III

Hi Thom,

U can use the following script.

if (len([finalCalledPartyNumber] )= 11,
Num(Right([finalCalledPartyNumber] ,10)),'0000000000') as [Final Called Number],
if (len([finalCalledPartyNumber] )= 4,
Num(Right([finalCalledPartyNumber] ,4)),'0000') as [Final VoIP Called Number],
if (len([finalCalledPartyNumber] ) = 3,
Num(Right([finalCalledPartyNumber],3)),'000') as [Final Common Called Number],

or

if (len(trim([finalCalledPartyNumber] ))= 11,
Num(Right([finalCalledPartyNumber] ,10)),'0000000000') as [Final Called Number],
if (len(trim([finalCalledPartyNumber] ))= 4,
Num(Right([finalCalledPartyNumber] ,4)),'0000') as [Final VoIP Called Number],
if (len(trim([finalCalledPartyNumber] )) = 3,
Num(Right([finalCalledPartyNumber],3)),'000') as [Final Common Called Number],

the TRIM function removes the white spaces from ur field values.

Regards

Manesh

tmumaw
Specialist II
Specialist II
Author

Thanks Manesh,

In your opinion which one is better to use?

Thom

maneshkhottcpl
Partner - Creator III
Partner - Creator III

Hi Thom,

The use of above is as per situation, If u dont want to count spaces(Left and write not inbetween words) in fiels then use second one, else use first one. But secondone in more efficient then first one.