Forum Discussion

sunny27's avatar
sunny27
Frequent Visitor
7 years ago

SQL to DAX

Hello All,

 

Can you please help me to write SQL query in DAX please. Below is the query

 

select count(*) from(
SELECT * FROM A WHERE ABTypeID
IN (10,11,12,13) and
BAID IN
(SELECT BAID FROM AB WHERE
CAID IN
(select CAID from ABC)))

 

Thanks!!

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You will need this add in tool from now on if you are building a lot of DAX queries in Excel for PowerPivot and Tabular.

     

    Go To this link:

     

    http://daxstudio.org/downloads/

     

    Select the most current, first, download.

     

    You can just run it after the download as a standalone app or open Excel and run it under Add In.

     

    DaxStudio has everything you need.

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi sunny27,

     

    It could be like below. But it depends on the data model structure. If you want a precise one, please provide a sample. 

    Measure =
    VAR baids =
        CALCULATETABLE ( VALUES ( ab[baid] ), ab[caid] IN VALUES ( abc[caid] ) )
    RETURN
        CALCULATE (
            COUNTROWS ( a ),
            a[abtypeid] IN { 10, 11, 12, 13 }
                && a[baid] IN baids
        )
    

    Best Regards,

    Dale