I am currently working on making some of our Transactions tables from an Oracle(ODBC) database available in Power BI based on an incremental refresh. So far I have loaded these tables or views via SQL into PBI. One of these reports has the following structure:
SELECT DB1.DGL AS "G/L Date",
CASE WHEN DB1.Code ='9B' THEN Replace(REGEXP_SUBSTR(DB1.Code , '(^|[+])[0-9]+'), '+', '')
FROM SERVER.DataBase1 DB1
WHERE DB1.Department LIKE '%EU%'
OR DB1.Department LIKE '%ASPAC%'
OR DB1.Department LIKE '%US%'
OR DB1.Department LIKE '%AUS%'
This code converts the column 'Code' into a specific format based on the CASE WHEN mentioned above.
How would you translate/ convert this part of code into an M-Function? Which one would you choose and how?
question from:https://stackoverflow.com/questions/65540667/converting-sql-case-when-to-power-query-m-syntax