Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lsullivan6311
Helper III
Helper III

Creating a Date column or measure with two existing columns, Month (Text) and Year (Text) formats

I need a date column for Chart visualizations to show month/year, current year vs prior year, but my columns are month (which is text and the month number, 1,2,3, etc.) and year (which is text).  How can I combine these into one column with YYYY-MM format?

2 ACCEPTED SOLUTIONS
sevenhills
Super User
Super User

Dax for the column YYYY-MM:

 

YYYY-MM = 'Table'[YYYY] & "-" & Right("00" & 'Table'[MM], 2)

 

 

YYYY ~ Number, MM ~ Text 

sevenhills_0-1648490381266.png

 

View solution in original post

v-eqin-msft
Community Support
Community Support

Hi @lsullivan6311 ,

 

I think @sevenhills 's method is the most convenient and it has solved your issue,so please kindly Accept his reply as the solution. More people will benefit from it. 

 

You could also try:

YYYY-MM = FORMAT(CONVERT(COMBINEVALUES(" ",[Year],[Month Number],"1") ,DATETIME),"YYYY-MM")

Eyelyn9_0-1648696621595.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @lsullivan6311 ,

 

I think @sevenhills 's method is the most convenient and it has solved your issue,so please kindly Accept his reply as the solution. More people will benefit from it. 

 

You could also try:

YYYY-MM = FORMAT(CONVERT(COMBINEVALUES(" ",[Year],[Month Number],"1") ,DATETIME),"YYYY-MM")

Eyelyn9_0-1648696621595.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sevenhills
Super User
Super User

Dax for the column YYYY-MM:

 

YYYY-MM = 'Table'[YYYY] & "-" & Right("00" & 'Table'[MM], 2)

 

 

YYYY ~ Number, MM ~ Text 

sevenhills_0-1648490381266.png

 

This gave me a column that looked like a date, but it does not seem to work as a date, since I cannot create a relationship between the date table and this new column.  I need to do this in order to get some calculations.

If you want it as date, then you need to adjust the Data Type and Format. Let us look again, I am providing three ways, you can decide any ONE 

 

a) You can create and use DAX columns as like below. Any one is good enough

YYYY-MM = 'Table'[YYYY] & "-" & Right("00" & 'Table'[MM], 2)

 

YYYY-MM2 = 'Table'[YYYY] & "-" & Right("00" & 'Table'[MM], 2) & "-01"

 

YYYY-MM-DD = Date('Table'[YYYY], 'Table'[MM], "01")

 

b) all newly created columns, select the data type as "Date"

 

sevenhills_0-1649089090085.png

 

Once you select the data type as date, you can choose the format of your choice.

- All three columns created are "date" data type

- format only varies

sevenhills_1-1649089207134.png

 

Hope this helps!

 

 

 

I have gotten a date column, formatted to be YYYY-MM-DD.  I wanted it to be end of month, but since I only had Year column and Month number column, I ended up using day 15 (I definitely did not want beginning of month).  I changed the data type to be Date and I chose YYYY-MM-DD, but Power BI now shows the date in this column as (example - Friday, February 15, 2015)  I do not want the day of the week.  Changing the format does not work.

That worked.  Thank you!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors