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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Anonymous
Not applicable

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors