Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

2 invoice fields from two different tables: INVHDRI is numeric,pkg 12 and DOCINV is character,pkd 10

in the Load Statement i can convert the INVHDRI by using char(INVHDRI) and then use a second step of len(INVHDRI,10) to get INVHDI to be character and length of 10.

How can i convert INVHDRI to character and tell Qlikveiw to make the length 10 in one formula instead of two or in one step instead of two steps?

Thank you for you help,

8 Replies
hector
Specialist
Specialist

Hi, if the field is a number, you can do

num(19,'0000000000')


and this will return 0000000019

is this what are you looking for?

Rgds

Not applicable
Author

He'ctor, yes the field is a number. By using your approach then i have no need for the Chr() and Len() combination.

So, num(INVHDRI,'0000000000) should give me INVHDRI as a character filed that is 10 characters long.

I'll try this and post if this doesnt work.

Not applicable
Author

He'ctor, yes the field is a number. By using your approach then i have no need for the Chr() and Len() combination.

So, num(INVHDRI,'0000000000) should give me INVHDRI as a character filed that is 10 characters long.

I'll try this and post if this doesnt work.

hector
Specialist
Specialist

I guess that works, because you don't post anything xD

Not applicable
Author

i tried it and it didnt work quite as i has hoped. I have an [ invoice field 1] that is numeric and i have another invoice field that is character [invoice field2].

if [invoice field1] is populated with 123456 then it will show up as 123,456 and [invoice field2] would show up as 123456 but as a character.

i tried to your recommended forumual on [invoice1] by typing num([ invoice field 1],'0000000000')

and the end result was 0000123456 which would not link to [invoice field2] since [invoice field2] would be populated with 123456.

So to rephrase my question, if i know that [invoice field2] is character field and the field is length 10, whcih means there can be up to 10 charachers in [invoice fiel2] but there doesnt have to be 10 characters.

Is there one formula compound formula that i can apply to [invoice field1] that would satisfy the above link issue?

thank you for your input, it is very much appreciated.

hector
Specialist
Specialist

Hi

did you try to use the num() function in both fields?, if the char field has spaces, use something like num(trim(field2),'0000000000')

Rgds

Not applicable
Author

would the same approach work to convert a number field into a character field with each record having 12 characters

chr(field),'0000000000')

Miguel_Angel_Baeyens

Hello,

You can use the following in both fields so they will always have the same format and values.

=Text(Repeat('0', 12 - Len(123456)) & '123456')


That will always return a text with leading zeroes as in the example above "0000123456".

Hope that helps.