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: 
nezuko_kamado
Creator
Creator

Combining two columns(variables) into one variable with adding zero and dash for reformatting

How to combine two variables into one variable that has different length of number? So the pseudo data is as below.

dat:
load * inline [ identification, acct
101111, 150
101111, 170
101112, 180
101112, 2000
101113, 200
101113, 1500];

and what I want to create is as below.

101111-0150
101111-0170
101112-0180
101112-2000
101113-0200
101113-1500

(1) I need to add zero if acct length is three digit. like 150=>0150

(2) then add '-' between identification and acct

Thank you!

1 Solution

Accepted Solutions
Saravanan_Desingh

Try this,

dat:
load *, identification&'-'&Num(acct,'0000') As Out inline [ 
identification, acct
101111, 150
101111, 170
101112, 180
101112, 2000
101113, 200
101113, 1500];

View solution in original post

4 Replies
Saravanan_Desingh

Try this,

dat:
load *, identification&'-'&Num(acct,'0000') As Out inline [ 
identification, acct
101111, 150
101111, 170
101112, 180
101112, 2000
101113, 200
101113, 1500];
Saravanan_Desingh

Output:

commQV73.PNG

nezuko_kamado
Creator
Creator
Author

What if the acct  consists with characters?, like

acct

N230

DR20

NPER

Then Num()  is not working...

 

brunobertels
Master
Master

may be this 

identification&'-'&

if(isnum(acct),num(acct,'0000'),acct) as out inline