Wednesday 20 May 2015

QlikView String Functions - Substring

QlikView String Functions - Substring

left( s , n )


Substring of the string s. The result is a string consisting of the first n characters of s.

Examples:
left( 'abcdef',3 ) returns 'abc'.


left( Date, 4 ) where Date = 1997-07-14 returns 1997.
For a more complicated example, see the index function below.


right( s , n )

Substring of the string s. The result is a string consisting of the last n characters of s.

Examples:
right('abcdef',3 ) returns 'def'.

right( Date,2 ) where Date = 1997-07-14 returns 14.


mid( s , n1 [ , n2 ] )n1: where to start postion 
n2:Number of characters

Substring of the string s. The result is the string starting at character n1 with the length of n2 characters. If n2 is omitted, the function returns the rightmost part of the string starting at character n1. The positions in the string are numbered from 1 and up.

Examples:
mid('abcdef',3 ) returns 'cdef'.
mid('abcdef',3, 2 ) returns 'cd'.
mid( Date,3 ) where Date = 970714 returns 0714
mid( Date,3,2 ) where Date = 970714 returns 07
For a more complicated example, see the index function below.

index( s1 , s2 [ , n ] )

Position of a substring. This function gives the starting position of the n:th occurrence of substring s2 in string s1. If n is omitted, the first occurrence is assumed. If n is negative, the search is made starting from the end of string s1. The result is an integer. The positions in the string are numbered from 1 and up.

Examples:
index( 'abcdefg', 'cd' ) returns 3
index( 'abcdabcd', 'b', 2 ) returns 6




index( 'abcdabcd', 'b', -2 ) returns 2
left( Date, index( Date,'-') -1 ) where Date = 1997-07-14 returns 1997
mid( Date, index( Date, '-', 2 ) -2, 2 ) where Date = 1997-07-14 returns 07








MSBI(SSRS,SSAS,SSIS), QlickView,Tableau Online Training

Visit us - www.BuddhaiSoft.com

BuddhaISoft Development & Training
 Hyderabad
 Mobile: +91 - 7799895236 / +91 - 7207401404

ContactUs@BuddhaiSoft.com

BuddhaiSoft@gmail.com

1 comment: