Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN 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')