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
Anonymous
Not applicable

Please help me convert DAX to Power Query

Hello All,

I am trying to convert the below DAX (Calculated column) function to a power query 

QEnd = IF(RIGHT('Table'[Quarter],2) = "Q1", Date(left('Table'[Quarter],4),03,31),

IF(RIGHT('Table'[Quarter],2) = "Q2", Date(left('Table'[Quarter],4),06,30),

IF(RIGHT('Table'[Quarter],2) = "Q3", Date(left('Table'[Quarter],4),09,30),

IF(RIGHT('Table'[Quarter],2) = "Q4", Date(left('Table'[Quarter],4),12,31)))))

 

I am trying to achieve the second column in the image using power query 

 

 

q.png

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Try this:

1) Go to Add Column tab and select Custom Column.

2) In code window, paste this:

 

if Text.End([Quarter], 2) = "Q1" then #date(Number.From(Text.Start([Quarter], 4)), 03, 31)
else if Text.End([Quarter], 2) = "Q2" then #date(Number.From(Text.Start([Quarter], 4)), 06, 30)
else if Text.End([Quarter], 2) = "Q3" then #date(Number.From(Text.Start([Quarter], 4)), 09, 30)
else if Text.End([Quarter], 2) = "Q4" then #date(Number.From(Text.Start([Quarter], 4)), 12, 31)
else null

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

4 REPLIES 4
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Try this:

1) Go to Add Column tab and select Custom Column.

2) In code window, paste this:

 

if Text.End([Quarter], 2) = "Q1" then #date(Number.From(Text.Start([Quarter], 4)), 03, 31)
else if Text.End([Quarter], 2) = "Q2" then #date(Number.From(Text.Start([Quarter], 4)), 06, 30)
else if Text.End([Quarter], 2) = "Q3" then #date(Number.From(Text.Start([Quarter], 4)), 09, 30)
else if Text.End([Quarter], 2) = "Q4" then #date(Number.From(Text.Start([Quarter], 4)), 12, 31)
else null

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Thank you for helping, I tried this there are no syntax errors although I do not get the desired results, am I missing something?

1.PNG

 

2.PNG 

@Anonymous ,

 

Sorry, I updated the code staright after I posted it with a correction.

Refresh your browser on this page then use the updated code please.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Thank you so much for helping this intern 🙂 

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.

Top Kudoed Authors