RBS

RBS

  • 1.5k
  • 204
  • 533

Translate SQL logic to DAX

Jan 29 2024 4:29 PM

Can someone help me adjust this SQL query to DAX : 

SELECT
    CASE
        WHEN EXTRACT(DAY FROM dates) = 1 AND EXTRACT(MONTH FROM dates) = 1 THEN 'Q4 ' || TO_CHAR(EXTRACT(YEAR FROM dates) - 1)
        WHEN EXTRACT(DAY FROM dates) = 1 AND EXTRACT(MONTH FROM dates) = 4 THEN 'Q1 ' || TO_CHAR(EXTRACT(YEAR FROM dates))
        WHEN EXTRACT(DAY FROM dates) = 1 AND EXTRACT(MONTH FROM dates) = 7 THEN 'Q2 ' || TO_CHAR(EXTRACT(YEAR FROM dates))
        WHEN EXTRACT(DAY FROM dates) = 1 AND EXTRACT(MONTH FROM dates) = 10 THEN 'Q3 ' || TO_CHAR(EXTRACT(YEAR FROM dates))
        ELSE NULL
    END AS " Quarter"
FROM
    myTable

I need to adjust the quarter in a seperate column


Answers (1)