Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I split some part of numbers of a field?

Hi every one,

suppose I have a field named AAA:

AAA

[139401,

139402,

139403,

139404,

139410,

139511]

I want to separate 2 numbers from the right of all this field values, in another word, I need to have toe field of AAA1 and AAA2:

AAA1       

[1394,

1394,

1394,

1394,

1394,

1395]

and AAA2

[01,

02,

03,

04,

10,

11]

As I need to use tow variables of AAA1 and AAA2 in different calculations, so I think that I must use some functions on the script!


I would appreciate it if some one can help me.

Thank you in advance,

Zahra

28 Replies
sunny_talwar

You can use a SubField() function:

For example if you have 1394|01 you can split it by doing this:

SubField('1394|01', '|', 1) -> 1394

SubField('1394|01', '|', 2) -> 01

HTH

Best,

Sunny

Not applicable
Author

Dear Marco Wedel,

Thank you a lot for your creative and helpful answer.

Best regards,

zahra

Not applicable
Author

Dear

Thank you a lot for your help.

Best,

Zahra

Not applicable
Author

All the answers are helpful and correct!

Now which of these must be mark as correct answer?

sunny_talwar

I think it doesn't matter, just randomly choose one as correct answer and reward others by marking there answer as helpful answer

Not applicable
Author

Ok, I will do that!

Not applicable
Author

Dear sunny,

If I have some data like below:

1394/01

1394/03

1395/10

...

.

I want to separate '01' , '03' , ..., so I use these functions:

table1:

load A,

subfield (A, '/', -2) as a1,

subfield (A, '/', -1) as a2,

from....

But it does not show a2 !

sunny_talwar

It does not show a2? what do you mean?

Can you try this:

table1:

load A,

subfield (A, '/', 1) as a1,

subfield (A, '/', 2) as a2,

Not applicable
Author

I wrote that as you wrote but If I use "," or  ";" after "subfield (A, '/', 2) as a2" it shows error and rest of the sentence ( from.....) begin red not blue!

and if I omit the signs, it works but shows dashes for a2 values!

sunny_talwar

I was not sure if you have more fields after a2 or not, but if you don't then do this:

table1:

load A,

        subfield (A, '/', 1) as a1,

        subfield (A, '/', 2) as a2

FROM source;