Power BI Zip Code Starting With 0

Are Zip Codes missing a zero in the front digit in Power BI? Don’t worry, This Power Bi tutorial will help you how to work with Zip Code Starting With 0 in Power BI. Also will cover the below topics:

  • Power BI Zip Code starting with 0
  • Power BI Zip Code leading zero

Power BI Zip Code starting with 0

  • It is possible to start a Zip Code with zero in the Power Bi.
  • For example, In the below screenshot, you can see the Ship to Zip Code column will be considered as an input column (like 595, 9625, etc.) and the Real Zip Code column (00595, 09625, etc.) will be the expected output column after adding the leading zero values.
Power BI Zip Code starting with zero
Power BI Zip Code starting with zero

So Let us see how we can display the zip code starting with 0 in Power Bi.

In this example we will use the Products Ordered Excel Spreadsheet as a data source, you can download and use it in the Power Bi report.

In the below screenshot of the Excel sheet, the Ship to Zip Column is of a number data type that is not accepting the Zip Code starting with 0 in Power BI.

Power BI Zip Code starting with 0 example
Power BI Zip Code starting with 0 example

To add a zero in front of the Zip Codes in Power BI, follow the instructions below:

  • Log in to the Power Bi desktop and load the data into it, Once the data has been loaded click on the new column under the modeling tab and use the below DAX formula:
  • The below-mentioned formula helps us to transform the multiple zip code values, for example, if the length of the zip code value is 5 then it will display the same 5 zip code values, else the length of the zip code is 4 then it will add a leading zero with the zip code.
  • If the length of the zip code is 3 then it will add two leading zeros with the zip code in the new column.
RealZipCode = 
SWITCH(
    TRUE(),
    LEN('Products Ordered'[Ship to Zip Code]) = 5, 'Products Ordered'[Ship to Zip Code],
    LEN('Products Ordered'[Ship to Zip Code]) = 4, "0" & 'Products Ordered'[Ship to Zip Code],
   LEN('Products Ordered'[Ship to Zip Code]) = 3, "00" & 'Products Ordered'[Ship to Zip Code]
)

Where,

  1. RealZipCode = New Column Name
  2. Products Ordered = Table Name
  3. Ship to Zip Code = Existing column name
See also  Power BI Month over Month Change [With Examples]

In the below screenshot, you can see that the new column has added the leading zero’s to the Zip code based on the condition applied.

Example of Power BI Zip Code starting with 0
Example of Power BI Zip Code starting with 0

This is how we can display the zip code starting with 0 in Power Bi.

Power BI Zip Code leading zero

  • It is possible to start a Zip Code with zero in Power Bi.
  • For example, In the below screenshot, you can see the Ship to Zip Code column will be considered as an input column (like 9625, etc.) and the Real Zip Code column (09625, etc.) will be the expected output column after adding the leading zero values.
Power BI Zip Code leading zero values
Power BI Zip Code leading zero values

So let us see how we can add a leading zero for the single Zip Code using the Power Bi Dax in Power BI.

In the example, we will see how to add a leading zero only for the selected or particular zip code value as highlighted below:

Power BI Zip Code leading zero values
Power BI Zip Code leading zero values

To achieve it follow the below steps:

  • Log in to the Power Bi desktop and load the data into it, Once the data has been loaded click on the new column under the modeling tab and use the below DAX formula:
  • The below-mentioned formula helps us to transform the selected zip code values, for example, if the length of the zip code is 4 then it will add a leading zero with the zip code in the new column.
RealZipCode = 
IF( LEN( [Ship to Zip Code] ) = 4,
    CONCATENATE( "0", [Ship to Zip Code] ),
    [Ship to Zip Code]
)

Where,

  1. RealZipCode = New Column Name
  2. Ship to Zip Code = Existing column name
See also  Difference Between Calculated Column and Measure in Power BI

In the below screenshot, you can see that the new column has added the leading zero’s to the specified Zip code based on the condition applied.

Power BI Zip Code leading zero
Power BI Zip Code leading zero

This is how to add a leading zero for the single Zip Code using the Power Bi Dax in Power BI.

In this Power Bi tutorial, we have learned how to work with Zip Code Starting With 0 in Power BI. Also, we covered the below topics:

  • Power BI Zip Code starting with 0
  • Power BI Zip Code leading zero

You may also like the below Power BI tutorials:

>