Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Convert SQL to DAX

 

SELECT
      newid() AS fact_tiger_id,
      comply.*, 
      CASE
        WHEN comply.tiger_point = 4 THEN 100
        ELSE 0
      END tiger_percentage
    FROM
    (
        SELECT
        process.*
        ,(SELECT
              CASE    
                  WHEN ROUND(CAST((SUM(is_comply)/COUNT(is_comply))*100 AS DOUBLE),0) = 100 then 1
                  ELSE 0
              END
          FROM fact_tiger_process 
          WHERE
            report_category_id = process.report_category_id
            AND date_id = process.date_id
            AND store_id = process.store_id
        ) AS comply_percategory
        ,(SELECT
              CASE    
                  WHEN ROUND(CAST(SUM(is_comply) AS DOUBLE),2) = 0 then 0
                  ELSE FLOOR(CAST((SUM(is_comply)/COUNT(is_comply))*100 AS DOUBLE))
              END
          FROM fact_tiger_process 
          WHERE
            report_category_id = process.report_category_id
            AND date_id = process.date_id
            AND store_id = process.store_id
        ) AS comply_percentage_percategory
        ,(SELECT SUM(comply_indicator)
          FROM temp_comply_indicator 
          WHERE
            date_id = process.date_id
            AND store_id = process.store_id
    ) AS tiger_point -- Summary total point from report category
    FROM
    (SELECT * FROM fact_tiger_process) process
    ORDER BY process.date_id, process.visit_id
    ) comply

 

I am trying to convert this SQL script into PBI DAX into Measure. Can anyone help? Anything would be appreciated. Thanks. 

1 REPLY 1
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you don't have to convert.

Power Query gives you the flexibility to import data from wide variety of databases that it supports. It can run native database queries, which can save you the time it takes to build queries using the Power Query interface. 

vstephenmsft_0-1638425075225.png

For more details, please refer to

Import data from a database using native database query | Microsoft Docs

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.