cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
djordan27
Helper I
Helper I

Converting Month into custom Year column

Hi there. 

 

I have a table (Dates) that looks like this.

 

MonthYear 

Jan 2017

2017

Feb 20172017
May 20182018
September 20192019
February 20202020 (pre covid)
March 20202020 (post covid)
June 20202020 (post covid)
Jan 20212021

 

I am looking to create a column (in red) to explore the impact pre and post covid so that it will just give me the year for 2018, 2019 and 2021 but for 2020 it splits it into two i.e. Jan 2020 and Feb 2020 = 2020 (pre covid) and March 2020 onwards = 2020 (post covid)

 

Could anyone help with this as this is quite complex?

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@djordan27 

do you have a date column? if you have a date column, you can try this

year = if(year('Date'[Date])=2020 && month('Date'[Date]) in {1,2},"2020 pre covid",if(year('Date'[Date])=2020,"2020 post covid",FORMAT('Date'[Date],"yyyy")))




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@djordan27 

do you have a date column? if you have a date column, you can try this

year = if(year('Date'[Date])=2020 && month('Date'[Date]) in {1,2},"2020 pre covid",if(year('Date'[Date])=2020,"2020 post covid",FORMAT('Date'[Date],"yyyy")))




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Marik
Solution Supplier
Solution Supplier

@djordan27 Create next calculated columns:

'Year' - original year;

'Month' - month's number (january - 1, february - 2 etc.)

'customYear': SWITCH(TRUE(),

                       'Year'=2020&&'Month'<=2,"2020 (pre covid)",

                       'Year'=2020&&'Month'>2,"2020 (post covid)",

                       'Year')

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors