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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
koorosh
Post Partisan
Post Partisan

YearMonth Column

Hello All, Why I can not create the YearMonth column in the linked file through the following DAX :

Date = FORMAT(DATE('Table'[YERR],'Table'[Month],1),"MM-YYYY")

How I can create it?

 

Regards

https://drive.google.com/file/d/10bitgpHEhLOifBtmQVVOJThQhfjDH_Wb/view?usp=sharing

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

You will need to use following

= FORMAT(DATE(YEAR('Calendar'[Year]),'Calendar'[Month Number],1),"MM-YYYY")

In your YEAR column, you have used STARTOFYEAR which gives a date. But in DATE, it needs a number for YEAR. YEAR('Calendar'[Year]) provides that year number.

Second problem was that you were using month name as second argument for Date whereas it needed a number 1-12 which should have been provided through 'Calendar'[Month Number].

View solution in original post

7 REPLIES 7
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Looks like you have misspelled Year as YERR that is why you must be getting error.

Since, your pbix file refers to a csv file, hence data is not visible to me. But you can always refer to date field itself. i.e. even following would work

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

 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Use this

Year Month = FORMAT('Calendar'[Date],"MM-YYYY")

1.png

Where is the problem with the following, please ?

MonthYear = FORMAT(DATE('Calendar'[YEAR],'Calendar'[Month Name],1),"MM-YYYY")
 

koorosh_0-1651925655178.png

 

 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

You will need to use following

= FORMAT(DATE(YEAR('Calendar'[Year]),'Calendar'[Month Number],1),"MM-YYYY")

In your YEAR column, you have used STARTOFYEAR which gives a date. But in DATE, it needs a number for YEAR. YEAR('Calendar'[Year]) provides that year number.

Second problem was that you were using month name as second argument for Date whereas it needed a number 1-12 which should have been provided through 'Calendar'[Month Number].

PaulDBrown
Community Champion
Community Champion

Try:

MonthYear = FORMAT(Table[Month], "00") & "-" & Table[Year]





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Where is the problem with the following, please?

MonthYear = FORMAT(DATE('Calendar'[YEAR],'Calendar'[Month Name],1),"MM-YYYY")

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors