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: 
Not applicable

How to concatenate two numeric fields in Qlikview script?

I need to concatenate two numeric fields when loading data from a SQL table into Qlikview. I have tried converting the numeric values into text first but have not been successful. The two approaches I have taken are (note: I have tried these approaches separately):

1. In the LOAD statement, I have used Qlikview's Text() function - e.g. Text(Field1) & Text(Field2) AS NewField

2. In the SQL SELECT statement, I have used SQL's Cast() function - e.g. Cast(Field1 as char) + Cast(Field2 as char) AS NewField

In case 1 I get no values for NewField. In case 2, the debugger states that I am missing an operator (eventhough the same syntax works in SQL Server).

Does anyone have any idea how to do this? Your feedback is greatly appreciated.

Labels (1)
1 Solution

Accepted Solutions
amit_shetty78
Creator II
Creator II

Hi,

I tried this and both the options worked for me. I have attached the script for your reference:



table1:
LOAD feature,
Visitors,
Year,
Text(Visitors) as txVisitors,
Text(Year) as txYear,
Text(Visitors)&Text(Year) as TextConcat
FROM (biff, embedded labels, table is Sheet2$);
end if
numsum:
ODBC CONNECT TO dw;
SQL select cast(1 as char(1)) as num1,
cast(2 as char(1)) as num2,1+2 as numsum,
cast(1 as char(1))+cast(2 as char(1)) as concat;


Hope this helps.

-Amit.



View solution in original post

2 Replies
amit_shetty78
Creator II
Creator II

Hi,

I tried this and both the options worked for me. I have attached the script for your reference:



table1:
LOAD feature,
Visitors,
Year,
Text(Visitors) as txVisitors,
Text(Year) as txYear,
Text(Visitors)&Text(Year) as TextConcat
FROM (biff, embedded labels, table is Sheet2$);
end if
numsum:
ODBC CONNECT TO dw;
SQL select cast(1 as char(1)) as num1,
cast(2 as char(1)) as num2,1+2 as numsum,
cast(1 as char(1))+cast(2 as char(1)) as concat;


Hope this helps.

-Amit.



Not applicable
Author

Thanks very much for your reply - very helpful!