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! Request now

Reply
Anonymous
Not applicable

Convert YEAR QRT into a type Date

I have 2 YEAR QUARTER columns and I want to subtract them to find how many Qarters apart they are

 

format of each column is "2021 Q3"

 

PQ returns are  erro if I try to convert to Date.  whats the best way to manipulate in-column to create a Date type from this format?

 

thanks

2 ACCEPTED SOLUTIONS
edhans
Super User
Super User

The following formula in a new column will convert that to the last day of the quarter.

Date.EndOfMonth(#date(Number.From(Text.Start([Quarter], 4)),Number.From(Text.End([Quarter], 1)) * 3, 1))

edhans_0-1701960341168.png

From there you can move it to the first day of the quarter using Date.AddMonths(the date, -3) and then use Date.StartOfMonth() to move that to the first day of the month.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

slorin
Super User
Super User

Hi,

 

4*(Number.From(Text.Start([YEAR QUARTER 2],4))
-Number.From(Text.Start([YEAR QUARTER 1],4)))
+Number.From(Text.End([YEAR QUARTER 2],1))
-Number.From(Text.End([YEAR QUARTER 1],1))

2021 Q3 --> 2022 Q1 

4*(2022 -2021) + 1 - 3 = 2  Quarters

 

Stéphane

 

View solution in original post

2 REPLIES 2
slorin
Super User
Super User

Hi,

 

4*(Number.From(Text.Start([YEAR QUARTER 2],4))
-Number.From(Text.Start([YEAR QUARTER 1],4)))
+Number.From(Text.End([YEAR QUARTER 2],1))
-Number.From(Text.End([YEAR QUARTER 1],1))

2021 Q3 --> 2022 Q1 

4*(2022 -2021) + 1 - 3 = 2  Quarters

 

Stéphane

 

edhans
Super User
Super User

The following formula in a new column will convert that to the last day of the quarter.

Date.EndOfMonth(#date(Number.From(Text.Start([Quarter], 4)),Number.From(Text.End([Quarter], 1)) * 3, 1))

edhans_0-1701960341168.png

From there you can move it to the first day of the quarter using Date.AddMonths(the date, -3) and then use Date.StartOfMonth() to move that to the first day of the month.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.