Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sculptorlv
Creator III
Creator III

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
tresesco
MVP
MVP

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 <>;

View solution in original post

5 Replies
tresesco
MVP
MVP

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
Creator III
Creator III
Author

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

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%'

tresesco
MVP
MVP

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
Creator III
Creator III
Author

Thank you!

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