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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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,

Labels (1)
1 Solution

Accepted Solutions
rbecher
Partner - Master III
Partner - Master III

Then you have to use if() function:

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

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine

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
Partner - Master III
Partner - Master III

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

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
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
Partner - Master III
Partner - Master III

Better try alt() function:

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

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
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
Partner - Master III
Partner - Master III

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

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
Anonymous
Not applicable
Author

Ok, thanks.

It didn't work

rbecher
Partner - Master III
Partner - Master III

Please see attached example with your data..

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
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.