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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Converting SQL into DAX

Can anyone help me to convert below SQL into DAX?

"

SELECT *
FROM VW_PTP_NC_PHASE
WHERE VW_PTP_NC_PHASE[NC Number]
        IN (SELECT VW_PTP_NC_PHASE[NC Number]
            FROM VW_PTP_NC_PHASE

            WHERE VW_PTP_NC_PHASE[Workflow Phase Name]="Closed") "

 

 

Thank you.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi there,

Here is how I would translate this to a DAX query:

EVALUATE
VAR NC_Number_Filter =
    CALCULATETABLE (
        VALUES ( W_PTP_NC_PHASE[NC Number] ),
        VW_PTP_NC_PHASE[Workflow Phase Name] = "Closed"
    )
RETURN
    CALCULATETABLE ( VW_PTP_NC_PHASE, NC_Number_Filter )

Where are you intending to use this?

There may be other considerations depending on the context, but essentially the same code should work elsewhere, such as in a measure.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
devanshi
Helper V
Helper V

 Dax format =   FILTER( VW_PTP_NC_PHASE,
                                     CONTAINS( VALUES(VW_PTP_NC_PHASE[NC Number]),
                                                          CALCULATETABLE( VALUES(VW_PTP_NC_PHASE[NC Number]),                                                                 VW_PTP_NC_PHASE[Workflow Phase Name] = "Closed" ), VW_PTP_NC_PHASE[NC Number]                                        )
                             )

OwenAuger
Super User
Super User

Hi there,

Here is how I would translate this to a DAX query:

EVALUATE
VAR NC_Number_Filter =
    CALCULATETABLE (
        VALUES ( W_PTP_NC_PHASE[NC Number] ),
        VW_PTP_NC_PHASE[Workflow Phase Name] = "Closed"
    )
RETURN
    CALCULATETABLE ( VW_PTP_NC_PHASE, NC_Number_Filter )

Where are you intending to use this?

There may be other considerations depending on the context, but essentially the same code should work elsewhere, such as in a measure.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.