Power Query Problems

Create a Year-Month Text Column in Excel Power Query

Olivia MillerOlivia Miller Dec 2, 2026 868 views

Question details

Create a Power Query text column containing a fixed prefix, a year, and a two-digit month, even when the source has no date column.

Create a Year-Month Text Column in Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
The user wants values such as TEST 202208 in a custom column.
Observed behavior
The desired column combines a fixed label with a four-digit year and a zero-padded month.
Before you start

Open the query in Power Query Editor and check whether the source has separate Year and Month columns. If it does not, decide whether to use a fixed period or the current date at refresh.

Solution 1Recommended

Combine Year and Month Columns in Power Query

Use this method when the query already has separate Year and Month columns, whether they contain numbers or text.

1
Open the query

In Excel, select Data > Queries & Connections, then double-click the query to open Power Query Editor.

2
Add a custom column

Select Add Column > Custom Column and enter a name such as YearMonthText.

3
Enter the formula

In the custom column formula box, enter "TEST " & Text.From([Year]) & Text.PadStart(Text.From([Month]), 2, "0"). Replace Year and Month with your exact column names if they differ.

4
Apply the result

Select OK, check that a year of 2022 and month of 8 produce TEST 202208, then select Home > Close & Load.

Combine Year and Month Columns in Power Query
Check the source values: The formula assumes valid year and month values. Text.PadStart adds a leading zero to a one-digit month but does not validate the month or shorten longer values.
Free Microsoft Office alternative

Work With Year-Month Data in WPS Spreadsheet

WPS Office is a free, lightweight alternative with a familiar interface for working with spreadsheets and moving existing files. WPS Spreadsheet can format year-month values with worksheet formulas, but it does not fix Excel Power Query or replace its query refresh workflow.

Use spreadsheet formulas to build year-month text valuesOpen and edit Microsoft Excel XLSX and XLS filesNavigate a familiar spreadsheet interfaceMove existing spreadsheets into a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

How do I add a leading zero to the month?

In Add Column > Custom Column, use Text.PadStart(Text.From([Month]), 2, "0"). For example, a month value of 8 becomes 08.

Do I need a date column to create TEST 202208?

No. You can combine separate Year and Month columns, enter a fixed year and month in a custom column, or derive the current period with DateTime.LocalNow().

Can I use the formula if Year and Month are already text?

Yes. Text.From works with text values as well as numbers. If the month text already has two digits, you can also use "TEST " & [Year] & [Month].

Why did the current year-month value change?

A formula using DateTime.LocalNow() is recalculated when the query refreshes. Use fixed values in Add Column > Custom Column if the period should remain unchanged.