cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dash_board2021
Regular Visitor

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 @dash_board2021 ,

 

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

View solution in original post

4 REPLIES 4
BA_Pete
Super User
Super User

Hi @dash_board2021 ,

 

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

View solution in original post

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 

@dash_board2021 ,

 

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

Thank you so much for helping this intern 🙂 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.