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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors