Forum Discussion

jainesh12's avatar
jainesh12
Frequent Visitor
3 years ago
Solved

SQL Query to DAX

SELECT customer_id, SUM(amount) AS total_sales
FROM orders
GROUP BY customer_id;

How can I convert it to a DAX function?
Is there any AI tool that converts SQL queries to DAX functions? (Except ChatGPT)

  • Hi jainesh12 
    If you are creting a measure then simply

    total_sales = SUM ( Orders[Amount] )

    If you want to create a calculated table

    OrdersByCustomer =
    SUMMARIZE ( Orders, Orders[Customer_id], "total_sales", SUM ( Orders[Amount] ) )

3 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi jainesh12 
    If you are creting a measure then simply

    total_sales = SUM ( Orders[Amount] )

    If you want to create a calculated table

    OrdersByCustomer =
    SUMMARIZE ( Orders, Orders[Customer_id], "total_sales", SUM ( Orders[Amount] ) )
    • jainesh12's avatar
      jainesh12
      Frequent Visitor

      tamerj1 Thank you for the suggestion.
      This was just an example, do you know is their any requirement to convert SQL queries to DAX functions?
      If yes, please suggest a few scenarios.

      • tamerj1's avatar
        tamerj1
        Community Champion

        jainesh12 
        There is no convertor, but you may try asking ChatGPT.