cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LyonsBI_BRL
Helper III
Helper III

PowerQuery - Registration Year using M

I'm looking to figure this out on how to set it so if the registrations dates are between May 3rd, 2021 and May 3rd, 2022 its FY22. Anything after May 4th, 2022 and beyond is FY23

 

Table.AddColumn(#"Changed Type2", "Registration Year", each if [FirstNewDate] >= #datetime(2021, 5, 3, 0, 0, 0) then "FY22" else if [FirstNewDate] < #datetime(2022, 5, 3, 0, 0, 0) then "FY22" else if [FirstNewDate] >= #datetime(2022, 5, 4, 0, 0, 0) then "FY23" else "FY23"),

 

Instead of it ouputting for any dates past May 4th, 2022 as FY23 it's listing them as FY22. Any suggestions as to why this is happening?

 

Thanks! 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use this

= Table.AddColumn(#"Changed Type", "Registration Year", each if Date.From([FirstNewDate])>=#date(2021,5,3) and Date.From([FirstNewDate])<=#date(2022,5,3) then "FY22" else "FY23")

 

View solution in original post

2 REPLIES 2
LyonsBI_BRL
Helper III
Helper III

@Vijay_A_Verma this is why I love this community! :D. Thank you that worked like a charm! 

Vijay_A_Verma
Super User
Super User

Use this

= Table.AddColumn(#"Changed Type", "Registration Year", each if Date.From([FirstNewDate])>=#date(2021,5,3) and Date.From([FirstNewDate])<=#date(2022,5,3) then "FY22" else "FY23")

 

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors