Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Combine 2 variable in 1

Hi all,

Very easy question. How combine 2 variable in 1 in load?

Var1Var2
0

4
7
9
2
6

8
4
9

10
3
7
5

Thanks,

1 Solution

Accepted Solutions
rbecher
MVP
MVP

Then you have to use if() function:

if(len(trim(Var1))=0, Var2, Var1)

- Ralf

Astrato.io Head of R&D

View solution in original post

13 Replies
Not applicable
Author

If you want to combine the columns, you could do this:

Var 1 & '' & Var 2 as Var12

You could do this on import or add it as a dimension afterwards.

Best,

Matt

rbecher
MVP
MVP

Hi Vladimir,

if this is a two column source and either  Var1 or Var2 is null or empty you can just concatenate by "&" and then convert to number:

LOAD num(num#(Var1 & Var2)) as Result ...;

- Ralf

Astrato.io Head of R&D
Anonymous
Not applicable
Author

Thanks guys for your help.

For some records I have duplicate

IDVar1Var2Result
802800002701502010
10
80280000270151608
8
8028000027015450
44
80280000270155901111
80280000270156001111
802800002701606010101010
8028000027016210
802800002701756010
10
8028000027017700
00
8028000027017780
802800002701784055

I need only 1 number. Use condition If? or maybe you more logical function?

Thanks,

rbecher
MVP
MVP

Better try alt() function:

LOAD alt(Var1,Var2) as Result ...;

- Ralf

Astrato.io Head of R&D
Anonymous
Not applicable
Author

Thanks Ralf,

It works!!!

Alt doesn't work with string variable?

    alt("Var1_number","Var2_number") as "Result1",    works

    alt("Var3_string","Var4_string") as "Result2",        doesn't work

it keeps only last variable data.

rbecher
MVP
MVP

Of course alt() function is for numeric data, please take a look into the help.

Therefor, this should work:

LOAD alt(num#(Val1), num#(Val2)) as Result ..

- Ralf

Astrato.io Head of R&D
Anonymous
Not applicable
Author

Ok, thanks.

It didn't work

rbecher
MVP
MVP

Please see attached example with your data..

Astrato.io Head of R&D
Anonymous
Not applicable
Author

Thanks Ralf for sharing the file.

I don't have problem with alt function for numeric variable.

I need to do the same for string variable.

Thanks again.