Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
WE ARE LISTENING! New Navigation for Qlik Community, Sept. 26: TELL ME MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
santho_ak
Partner - Creator III
Partner - Creator III

Number formatting- Adding Zeros

Hi,

I need to format number in the dimension. 

Current- Postal Code:

60051-1432

53243

60165-1232

32190-4569

54401

Required Output:

Postal Code:

60051-1432

53243-0000

60165-1232

32190-4569

54401-0000

So if the data has 9 digit Postal code then I need it as it is. Else, I would need to add '-0000' after the 5 digits. Need help. Thanks

 

 

Labels (4)
1 Solution

Accepted Solutions
Kushal_Chawda

@santho_ak  try below

Postal_Code:
load *, if(index(Postal_Code,'-'),Postal_Code,Postal_Code&'-'&'0000') as Postal_Code_Formatted 
inline [
Postal_Code
60051-1432
53243
60165-1232
32190-4569
54401

View solution in original post

2 Replies
Kushal_Chawda

@santho_ak  try below

Postal_Code:
load *, if(index(Postal_Code,'-'),Postal_Code,Postal_Code&'-'&'0000') as Postal_Code_Formatted 
inline [
Postal_Code
60051-1432
53243
60165-1232
32190-4569
54401
Vegar
MVP
MVP

You could try this expression

Subfield([Postal Code], '-', 1) & '-' & alt(Subfield([Postal Code], '-', 2),'0000')