Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
Solved! Go to Solution.
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
Proud to be a Datanaut!
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
Proud to be a Datanaut!
Thank you for helping, I tried this there are no syntax errors although I do not get the desired results, am I missing something?
@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
Proud to be a Datanaut!
Thank you so much for helping this intern 🙂