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: 
louisernould
Contributor III
Contributor III

Select only some number with keepchar

Hi everybody,

I have a very big column with letter & numbers and I want to create a second column with only some numbers of the first one.

for exemple This is the table  I want

DesignationCode48
AAA 48 BA 12848
AA14-
BBB48A21448

So I tried with the Keepchar function:

Load

     Designation

      KeepChar(Designation, 48) as code48

From Table

But the problem is, when I try that code, I have this table

DesignationCode48
AAA 48 BA 128488
AA144
BBB48A214484

Does someone have an idea ? It's the end for me ^^

Thanks,

Louis

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try like:

Load

          If(Index(Designation, '48'), 48) as Code48

View solution in original post

7 Replies
tresesco
MVP
MVP

Try like:

Load

          If(Index(Designation, '48'), 48) as Code48

louisernould
Contributor III
Contributor III
Author

YOU ARE MY GOD !

Thank you very much it work !! And moreover it was fast ^^

Tresesco winner !

martynlloyd
Partner - Creator III
Partner - Creator III

If you want a robust method, to extract the first group of numbers (variable len), without using a loop, try something like


input:
Load * Inline [
desig
AAA 48 BA 128
AA14
CC24
BBB48A214
];

temp1:
LOAD
PurgeChar(desig,' ') AS desig,
FindOneOf(PurgeChar(desig,' ') , '0123456789') as start,
Mid(PurgeChar(desig,' '),FindOneOf(PurgeChar(desig,' ') , '0123456789'),len(PurgeChar(desig,' '))) as string2,
FindOneOf(Mid(PurgeChar(desig,' '),FindOneOf(PurgeChar(desig,' ') , '0123456789'),len(PurgeChar(desig,' '))) , 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
-1 as length

Resident input
;

Result:
LOAD
desig,
f(length<=0, mid(desig,start,len(desig) -(start-1)), mid(desig, start, length)) as code
Resident temp1
;

drop Table input, temp1;

regards,

M.

MarcoWedel

another one:

Pick(WildMatch(Designation,'*48*'),48) as Code48

anbu1984
Master III
Master III

If(Designation Like '%48%'), 48) as Code48

louisernould
Contributor III
Contributor III
Author

actually, all your answers are correct that's perfect !

Martyn Lloyd, yours is quite hard, but much robust. I needed only a simple solution. But thks anyway, I like the logic of it.

Not applicable

Very helpful