Power query concatenat leading zero

dicken

Active Member
Joined
Feb 12, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hi,
In power query I'd like to add a leading zero to month number below 10, I thought I would just be able to use
Excel Formula:
0 & Date.Month([date])
, no good did try putting 0 in {} , that didn't work either, is there a way to do this?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I suspect that only way would be if your month value were converted to text.
 
Upvote 0
I suspect that only way would be if your month value were converted to text.
Tried that, afraid not. What I wanted this for is as a sort column, I was using year month number, which works up to September but October comes along putting a leading 1 for 10, and so was ranked lower than the 9 for September, so I thought If I added a leading zero it might solve the problem.
 
Upvote 0
I suspect that only way would be if your month value were converted to text.
I've found this, I haven't tried it for sorting but i'ts the best I've got so far.

Excel Formula:
Text.PadStart(Text.From( Date.Month(#date(2000,1,1))),2,"0")
 
Upvote 0
I suspect that only way would be if your month value were converted to text.
Final update ;


Excel Formula:
Table.TransformColumnTypes( 
                               Table.AddColumn(#"Previous step", "Column Name",

                              each Text.PadStart(Text.From( Date.Month( [Date] ) ) ,2,"0")&
                                    Text.From( Date.Year([Date]) )), {  {"Column Name", type number }} )

Richard.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,396
Messages
6,171,866
Members
452,427
Latest member
samk379

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