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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
sunil-kumar5
Creator II
Creator II

Fixed the length and structure

Hi All,

I have a table where I just want that my table should only contain the ID column value in the proper structure which include first five with alphabet next three should be numeric and end with an alphabet so total length is 9, so as per below table I should only fetch the data for 4 rows (Name1,4,7 and Name10) only in a table. Please advise how to achieve this.

NameID
NAME1ASDFL302T
NAME2ERRDSKFDFFDFG
NAME3ADSF
NAME4LKJGH786F
NAME5456SDFFJG
NAME6T567LKHDD
NAME7ASERF987G
NAME8855898RREWRER
NAME9WQEREWT3
NAME10BJHGC456P

 

Thanks

Sunil Kumar

4 Solutions

Accepted Solutions
squreshi
Contributor II
Contributor II

 Hi Sunil,

You can filter the data at the script level for a fixed length of characters to 9 using Len(ID)=9 in the where clause.

And extract the numbers from the ID column using the Mid function.

squreshi_0-1632654385504.png

And then use the ISNUM function in the IF condition of the table to get the required result.

squreshi_3-1632654672840.png

squreshi_1-1632654613421.png

Please mark the solution as correct if you find it helpful and correct.

 

Thanks,

Squreshi

 

 

View solution in original post

Taoufiq_Zarra

@sunil-kumar5  if I undersood correctly

you can use Flag for this or use this function in a filtre

if(len(purgechar(left(ID,5),'0123456789'))=5 and len(KeepChar(mid(ID,6,3),'0123456789'))=3 and len(purgechar(right(ID,1),'0123456789'))=1,1,0),0)

 

like this in Script:

LOAD *,if(len(ID)=9,if(len(purgechar(left(ID,5),'0123456789'))=5 and len(KeepChar(mid(ID,6,3),'0123456789'))=3 and len(purgechar(right(ID,1),'0123456789'))=1,1,0),0) as Flag INLINE [
    Name, ID
    NAME1, ASDFL302T
    NAME2, ERRDSKFDFFDFG
    NAME3, ADSF
    NAME4, LKJGH786F
    NAME5, 456SDFFJG
    NAME6, T567LKHDD
    NAME7, ASERF987G
    NAME8, 855898RREWRER
    NAME9, WQEREWT3
    NAME10, BJHGC456P
];

 

output:

Taoufiq_Zarra_0-1632656491346.png

the you can use this Flag in Set analysis like sum({<Flag={1}>} Field)

or in load Script where Flag=1

...

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

Vegar
MVP
MVP

You can also use @Taoufiq_Zarra's logic for filtering while loading your data, like this.

 

LOAD *
INLINE [
    Name, ID
    NAME1, ASDFL302T
    NAME2, ERRDSKFDFFDFG
    NAME3, ADSF
    NAME4, LKJGH786F
    NAME5, 456SDFFJG
    NAME6, T567LKHDD
    NAME7, ASERF987G
    NAME8, 855898RREWRER
    NAME9, WQEREWT3
    NAME10, BJHGC456P
]
WHERE
    len(ID)=9 
    AND len(purgechar(left(ID,5),'0123456789'))=5 
    AND len(KeepChar(mid(ID,6,3),'0123456789'))=3 
    AND len(purgechar(right(ID,1),'0123456789'))=1 
;

View solution in original post

Saravanan_Desingh

One more solution, using pattern match. A- Alpha; N - Num

 

 

tab1:
LOAD *, If(Index('ABCDEFGHIJKLMNOPQRSTUVWXYZ',Mid(ID,IterNo(),1)),'A',
	If(Index('1234567890',Mid(ID,IterNo(),1)),'N',Mid(ID,IterNo(),1))) As P1,
	IterNo() As S1
While IterNo()<=Len(ID);
LOAD * INLINE [
    Name, ID
    NAME1, ASDFL302T
    NAME2, ERRDSKFDFFDFG
    NAME3, ADSF
    NAME4, LKJGH786F
    NAME5, 456SDFFJG
    NAME6, T567LKHDD
    NAME7, ASERF987G
    NAME8, 855898RREWRER
    NAME9, WQEREWT3
    NAME10, BJHGC456P
];

Left Join(tab1)
LOAD Name, ID, If(Concat(P1,'',S1)='AAAAANNNA','Y','N') As Flag
Resident tab1
Group By Name, ID;

 

 

commQV06.PNG

View solution in original post

5 Replies
squreshi
Contributor II
Contributor II

 Hi Sunil,

You can filter the data at the script level for a fixed length of characters to 9 using Len(ID)=9 in the where clause.

And extract the numbers from the ID column using the Mid function.

squreshi_0-1632654385504.png

And then use the ISNUM function in the IF condition of the table to get the required result.

squreshi_3-1632654672840.png

squreshi_1-1632654613421.png

Please mark the solution as correct if you find it helpful and correct.

 

Thanks,

Squreshi

 

 

Taoufiq_Zarra

@sunil-kumar5  if I undersood correctly

you can use Flag for this or use this function in a filtre

if(len(purgechar(left(ID,5),'0123456789'))=5 and len(KeepChar(mid(ID,6,3),'0123456789'))=3 and len(purgechar(right(ID,1),'0123456789'))=1,1,0),0)

 

like this in Script:

LOAD *,if(len(ID)=9,if(len(purgechar(left(ID,5),'0123456789'))=5 and len(KeepChar(mid(ID,6,3),'0123456789'))=3 and len(purgechar(right(ID,1),'0123456789'))=1,1,0),0) as Flag INLINE [
    Name, ID
    NAME1, ASDFL302T
    NAME2, ERRDSKFDFFDFG
    NAME3, ADSF
    NAME4, LKJGH786F
    NAME5, 456SDFFJG
    NAME6, T567LKHDD
    NAME7, ASERF987G
    NAME8, 855898RREWRER
    NAME9, WQEREWT3
    NAME10, BJHGC456P
];

 

output:

Taoufiq_Zarra_0-1632656491346.png

the you can use this Flag in Set analysis like sum({<Flag={1}>} Field)

or in load Script where Flag=1

...

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Vegar
MVP
MVP

You can also use @Taoufiq_Zarra's logic for filtering while loading your data, like this.

 

LOAD *
INLINE [
    Name, ID
    NAME1, ASDFL302T
    NAME2, ERRDSKFDFFDFG
    NAME3, ADSF
    NAME4, LKJGH786F
    NAME5, 456SDFFJG
    NAME6, T567LKHDD
    NAME7, ASERF987G
    NAME8, 855898RREWRER
    NAME9, WQEREWT3
    NAME10, BJHGC456P
]
WHERE
    len(ID)=9 
    AND len(purgechar(left(ID,5),'0123456789'))=5 
    AND len(KeepChar(mid(ID,6,3),'0123456789'))=3 
    AND len(purgechar(right(ID,1),'0123456789'))=1 
;
sunil-kumar5
Creator II
Creator II
Author

Thank you so much, you all have given the great response and I am able achieve this.

 

Saravanan_Desingh

One more solution, using pattern match. A- Alpha; N - Num

 

 

tab1:
LOAD *, If(Index('ABCDEFGHIJKLMNOPQRSTUVWXYZ',Mid(ID,IterNo(),1)),'A',
	If(Index('1234567890',Mid(ID,IterNo(),1)),'N',Mid(ID,IterNo(),1))) As P1,
	IterNo() As S1
While IterNo()<=Len(ID);
LOAD * INLINE [
    Name, ID
    NAME1, ASDFL302T
    NAME2, ERRDSKFDFFDFG
    NAME3, ADSF
    NAME4, LKJGH786F
    NAME5, 456SDFFJG
    NAME6, T567LKHDD
    NAME7, ASERF987G
    NAME8, 855898RREWRER
    NAME9, WQEREWT3
    NAME10, BJHGC456P
];

Left Join(tab1)
LOAD Name, ID, If(Concat(P1,'',S1)='AAAAANNNA','Y','N') As Flag
Resident tab1
Group By Name, ID;

 

 

commQV06.PNG