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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
DemoFour
Responsive Resident
Responsive Resident

Create a Year Period column in M

Hi all, 

 

I have been learning M with the help of blogs to build a dimension table. I want to create a column for FY = 2020 - 2021

 

I can do this in Dax with 

Year Period = 
IF( 
    'Date'[Quarter Number] >= 4 , 
    'Date'[Year] - 1 & "-" & 'Date'[Year],
    'Date'[Year] & "-" & 'Date'[Year] +1
)

 

But if I do this in M then it does not like the & "-" & part

 

I guess this is an easy. . .  but I am new to M, but any help welcome on how to join the years with the + or - 1 please. 

 

Thanks 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

The equivalent M syntax would look like this (assuming your Date table is created with a query and is not a DAX table).  This also assumes your Year and Quarter columns are numbers (not text).  Note that M is case sensitive.

 

Year Period = 
if
    [Quarter Number] >= 4 then 
    Text.From([Year] - 1) & "-" & Text.From([Year]) else
    Text.From([Year]) & "-" & Text.From([Year] +1)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Try:

Year Period = VAR ly = TEXT(Date[Year]-1) VAR ny = TEXT(Date[Year]-1) VAR ty = TEXT(Date[Year] RETURN 

IF Date[Quarter Number] >= 4, ly&"-"&ty,

ty&"-"&ny 

 

--Nate

@Anonymous Thank you Nate, this did not work as written, but I will have an explore and see what I can do with your offered solution. 

 

Have a good day. 

mahoneypat
Microsoft Employee
Microsoft Employee

The equivalent M syntax would look like this (assuming your Date table is created with a query and is not a DAX table).  This also assumes your Year and Quarter columns are numbers (not text).  Note that M is case sensitive.

 

Year Period = 
if
    [Quarter Number] >= 4 then 
    Text.From([Year] - 1) & "-" & Text.From([Year]) else
    Text.From([Year]) & "-" & Text.From([Year] +1)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Morning @mahoneypat 

Thank you for the solution. 

 

Because I had made the Quarter Column with: 

 

= "Q" & [Quarter Number]

 


I just tried the same with the column names and & but I can see now that you need to use Text.From to tell the engine to take the value from the column and - 1

Thank you for posting up, have a good day Pat

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.