Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
ajipaul03
Contributor III
Contributor III

Dataload script - Use Exists in varchar field

Does anyone know how  to enforce data type while loading?

 

Here is my scenario , I have two tables  CODE_T and VALUE_T the column CODE is varchar 2 on both tables.

 

 

CODE_T

CODERank
011
022
031
41
5

1

 

VALUE_T

CODEDESCVAL
1test 120
2test 214
3test 365
4test 412
5test 56
6test 612

 

My script

CODE_T: 

LOAD CODE,  Rank
FROM [C:\Users\QLIK\TEST_DATA.xlsx](ooxml, embedded labels, table is CODE_T)
where Rank = 1;

VALUE_T

LOAD CODE, DESC, VAL
FROM [C:\Users\QLIK\TEST_DATA.xlsx](ooxml, embedded labels, table is VALUE_T)
where Exists (CODE) ;

 

What I am looking is to load only 4 & 5 into VALUE_T.  Do you know why Qlikview considers '01' is same as '1' ?

Do you know any way  we could enforce database's data types?

 

Thanks,

Aji

Labels (1)
1 Reply
Nicole-Smith

Since it looks like a num, Qlik assumes that's what it is.  If you want to ensure it's treated as text with the 0 in front, you could use the text() function when loading your fields:

CODE_T: 
LOAD text(CODE) AS CODE,  Rank
FROM [C:\Users\QLIK\TEST_DATA.xlsx](ooxml, embedded labels, table is CODE_T)
where Rank = 1;

VALUE_T:
LOAD text(CODE) AS CODE, DESC, VAL
FROM [C:\Users\QLIK\TEST_DATA.xlsx](ooxml, embedded labels, table is VALUE_T)
where Exists (CODE) ;