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

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Table:

LOAD AAA,

          Left(AAA, 4) as AAA1,

          Right(AAA, 2) as AAA2;

LOAD * Inline [

AAA

139401,

139402,

139403,

139404,

139410,

139511

];

Output

Capture.PNG

View solution in original post

28 Replies
Anonymous
Not applicable
Author

hi,

Please try;

left(ÁAA,4) as AAA1

mid(AAA,5) as AAA2

or

Right(AAA,4) as AAA2


Regards

Neetha

sunny_talwar

Try this:

Table:

LOAD AAA,

          Left(AAA, 4) as AAA1,

          Right(AAA, 2) as AAA2;

LOAD * Inline [

AAA

139401,

139402,

139403,

139404,

139410,

139511

];

Output

Capture.PNG

MarcoWedel

Left(AAA,Len(AAA)-2) as AAA1,

Right(AAA,2) as AAA2

If it's always 2 characters at the end and a variable length of AAA is possible.

Hope this helps

Regards

Marco

jafari_ervin
Creator III
Creator III

Dear Zahra,

Please use left () and Right() and mid() function to separate different part the shamsi date like below:

if AAAA format is something like YYYYMMDD (13941205)

load*,

left(AAA,4) as Date_Year,

mid(AAAA,5,2) as Date_Month,

Right(AAAA,2) as Date_Day,

From ...

Best Regards,

Not applicable
Author

Hello Zahra,

Hope this thing helps you out.

Main:

Load *,Left(AAA,4) as AAA1, Right(AAA,2) as AAA2;

Load * Inline [

AAA

139401,

139402,

139403,

139404,

139410,

139511

];


Thank you

MarcoWedel

‌Another solution for integer values only:

Mod(AAA,100) as AAA2

Div(AAA,100) as AAA1

regards

Marco

sunny_talwar

Very creative MarcoWedel

Not applicable
Author

Dear neetha,

Thank you for your help.

I used these functions on the front end say in a table, so I could not use the created variables in another tables or charts.

best,

Zahra

Not applicable
Author

Dear Sunny,

Thank you very much, I used mid () function on the front end but I could not use that on the script. Now I know where was my mistake!

I have another question that if there is a kind of separator, How can I split these two parts?

Regards,

zahra