Showing results for 
Search instead for 
Did you mean: 

How to join tables in case of key fields are ALPHA-converted (leading zeros)

Former Member
0 Kudos

Hello experts,

I would like to join a transactional data source table with a master data source table.

In the master data table, the key field "CUSTOMER" is ALPHA converted (leading zeros). In the transactional data table, the key field "CUSTOMER" is not ALPHA converted (w/o leading zeros).

How can I handle such scenarios if I have a key field with and w/o leading zeros. Is it´s possible to cut the leading zeros with the help of a formula or is it`s possible to convert the format from ALPHA-converted to not ALPHA-converted (w/o leading zeros)?

Example scenario:

Source table 1 (fact table) with transactional data:

Customer ID w/o leading zeros:

Source table 2 (dimension table) with customer master data each:

Customer ID with leading zeros (with the exception of customer C5300):

Star join with LEFT OUTER 1:1 JOIN between fact table and dimension table:


It´s not possible to bring the customer master data of the customers 5000, 5100 and 5200 to the output because the customer no. ID are not unique between the both source tables (customer no. id´s w/o leading zeros vs. leading zeros)

How can I solve the Issue?

Many thanks in advance!

Best regards,

Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

The easiest way would be to remove the leading zeros from the ALPHA input converted values, because the other way around - when you wanna add leading zeros - you have to do some more checks (e.g. checking if the value is not alphanumeric ...).

You can remove the leading zeros with the LTRIM function in a calculated column. E.g.


Of course for performance reasons it would be better to have the values already in the same format in your sources.


Former Member
0 Kudos

Hello Florian,

thank you. I´ve added a new calculated column to remove the leading zeros.

Now the join works as aspected.


Answers (0)