Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

sculptorlv
Contributor II

One column from two with single value

Hello! Hope for your help again!

I have the situation with SQL table. Following columns:

From     To                      OtherColumns

05T          909352                sdfdsfsfs

03T          346347347               sdfsdfsdf

8925235     05T                    sdfdfs

03T          sdf8325               466346dfgsg

23525ff       07T                    jlkjfaf lsaf

I need from two Columns From and To, get only one Column Location, where will be one value from FROM or TO. I am looking for these short values 05T, 03T, 06T etc. These are known for me.

The result must be:

Location      OtherColumns

05T               sdfdsfsfs

03T               sdfsdfsdf

05T               sdfdfs

03T               466346dfgsg

07T               jlkjfaf lsaf

Thank for your help in advance!

1 Solution

Accepted Solutions
MVP
MVP

Re: One column from two with single value

Try the code in qlikview load section rather than in sql, like:

Load

     *,

     If(Right(From,1)='T', From,

          If(Right(Tp,1)='T', To))  As Location

;

SQL Select

          <your fields>..

From <>;

5 Replies
MVP
MVP

Re: One column from two with single value

If you can decide on a pattern, like 'the last character' of from/to column always have 'T', try like:

If(Right(From,1)='T', From,

     If(Right(Tp,1)='T', To))  As Location

sculptorlv
Contributor II

Re: One column from two with single value

IF(Right(Tbl_DocumentHeaders."New FA Location Code",1)='T', Tbl_DocumentHeaders."New FA Location Code",

     IF(Right(Tbl_DocumentHeaders."FA Location Code",1)='T', Tbl_DocumentHeaders."FA Location Code")) AS Location,

I am getting syntax error (added to working QSL script), and can't find the reason:

111.jpg

Not applicable

Re: One column from two with single value

You could do something like:

Select "From" as Location,OtherColumns

  from table

  where   From like '%T%'

Union Select "To"  as Location, OtherColumns

  from table

where  "To" like '%T%'

MVP
MVP

Re: One column from two with single value

Try the code in qlikview load section rather than in sql, like:

Load

     *,

     If(Right(From,1)='T', From,

          If(Right(Tp,1)='T', To))  As Location

;

SQL Select

          <your fields>..

From <>;

sculptorlv
Contributor II

Re: One column from two with single value

Thank you!

My first Load ... finally understood how it works!

Community Browser