cancel
Showing results for
Did you mean:
Regular Visitor

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

1 ACCEPTED SOLUTION
Super User

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

4 REPLIES 4
Super User

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

Regular Visitor

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

Super User

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

Pete

Regular Visitor

Thank you so much for helping this intern 🙂

Announcements

#### Launching new user group features

Learn how to create your own user groups today!