PowerPivot - Padding with Zeros

ShaunP

New Member
Joined
Jul 5, 2018
Messages
10
I have a column of project numbers that vary in length. My plan is to write an IF statement to check the length of the Project Number and pad these numbers with 0 so that the formats are the same, max length of 10, if needed.

Current Project NumberNew Proj Num
PRJ3PRJ0000003
PRJ0000012PRJ0000012

<tbody>
</tbody>

I'm using the MID & Format functions to find the location to start padding but it's not working for me.

Code:
=FORMAT(MID([ProjectNumber],4,len([ProjectNumber])),"0000000")

Using the code above will give a result of 3 and 0000012 for the 2 examples above.

I'm using the PowerPivot plugin for Excel 2010 (version 11.0.5058.0). I appreciate the help!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
try:

=<br><span class="Keyword" style="color:#0070FF">LEFT</span><span class="Parenthesis" style="color:#969696"> (</span> [Current Project Number], <span class="Number" style="color:#EE7F18">3</span> <span class="Parenthesis" style="color:#969696">)</span><br>    & <span class="Keyword" style="color:#0070FF">REPT</span><span class="Parenthesis" style="color:#969696"> (</span> <span class="StringLiteral" style="color:#D93124">"0"</span>, <span class="Number" style="color:#EE7F18">10</span> - <span class="Keyword" style="color:#0070FF">LEN</span><span class="Parenthesis" style="color:#969696"> (</span> [Current Project Number] <span class="Parenthesis" style="color:#969696">)</span> <span class="Parenthesis" style="color:#969696">)</span><br>    & <span class="Keyword" style="color:#0070FF">MID</span><span class="Parenthesis" style="color:#969696"> (</span> [Current Project Number], <span class="Number" style="color:#EE7F18">4</span>, <span class="Number" style="color:#EE7F18">7</span> <span class="Parenthesis" style="color:#969696">)</span><br>
 
Upvote 0
try:

=
LEFT ( [Current Project Number], 3 )
& REPT ( "0", 10 - LEN ( [Current Project Number] ) )
& MID ( [Current Project Number], 4, 7 )

Thanks VBA Geek but that did not work. I get an error stating the REPT is the wrong data type. Both columns are formatted at Text.
 
Upvote 0
Looks like the REPT formula does not like this section 10 - LEN ( [Current Project Number] )
 
Upvote 0

Forum statistics

Threads
1,216,361
Messages
6,130,180
Members
449,563
Latest member
Suz0718

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top