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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
MuraliPrasath
Creator III
Creator III

I want to split my field values into two fields.

Hi,

I just want to split my field values into two values.

FiscalYr.Period                                     Year     Period

2013000                   into two fields        2013    000

1 Solution

Accepted Solutions
sunny_talwar

Try this:

LOAD Left(FiscalYr.Period, 4) as Year,

          Right(FiscalYr.Period, 3) as Period,

          FiscalYr.Period

FROM ....

View solution in original post

6 Replies
sunny_talwar

Try this:

LOAD Left(FiscalYr.Period, 4) as Year,

          Right(FiscalYr.Period, 3) as Period,

          FiscalYr.Period

FROM ....

Not applicable

Hi

Use,

Left(FiscalYr.Period,4) as Year,

right(FiscalYr.Period,3) as Period

Regards,

Snehal Nabar

swuehl
MVP
MVP

I would probably also use string functions like Left() and Right() to separate the value into two parts, but to suggest another option, maybe

Div(FiscalYr.Period,1000)  as Year

and

Mod(FiscalYr.Period,1000)  as Period

[Or

Num(Mod(FiscalYr.Period,1000),'000')  as Period

if you want to keep the three digit format]

BIG advantage if you need to account for  early medieval periods:

LOAD

    Div(FiscalYr.Period,1000)  as Year,

    Num(Mod(FiscalYr.Period,1000),'000')  as Period,

    FiscalYr.Period

INLINE [

FiscalYr.Period

800004

2013001

];



Peter_Cammaert
Partner - Champion III
Partner - Champion III

You don't have to change your script. It can be done in the UI like this:

Create two listboxes, and instead of a Field, select <Expression> from the list and enter these expressions:

=num(left(FiscalYr.Period, 4)) /* For the year part */

=num(right(FiscalYr.Period, 3)) /* For the Period */

If you want to keep leading zeroes, add a format string to the num() call. Like in

=num(right(FiscalYr.Period, 3), '000') /* For the Period */

Split Field into two thread216626.jpg

Peter

sunny_talwar

BIG advantage if you need to account for  early medieval periods:

You almost convinced me Stefan (not that it matters)

Anonymous
Not applicable

LOAD

     subfield(FIELD,'-',1) as F1,

     subfield(FIELD,'-',2) as F2,

     subfield(FIELD,'-',3) as F3,

     subfield(FIELD,'-',4) as F4,

...

FROM ...; try in this way