Forum Discussion

alhowarth's avatar
alhowarth
Helper I
5 years ago
Solved

DAX help please

I would like to create the DAX equivalent of this:

 

SELECT COUNT(JOB_NAME) JOB_COUNT
FROM MYDB.dbo.MY_TABLE
WHERE JOB_TYPE <> '98'
AND BOX_NAME <> ''

 

I can get the count using this:  JOB_COUNT = COUNT(MY_TABLE[JOB_NAME])

But can't seem to filter that to match my WHERE statements

  • alhowarth , Try like

    calculate(count(MY_TABLE[JOB_NAME]), filter(MY_TABLE, MY_TABLE[JOB_TYPE] ="98" && not(isblank(MY_TABLE[BOX_NAME])) ))

4 Replies

  • alhowarth 

    Give something like this a try.

     

    Filtered Count =
    CALCULATE (
        COUNT ( MY_TABLE[JOB_NAME] ),
        FILTER ( MY_TABLE, MY_TABLE[JOB_TYPE] = "98" && MY_TABLE[BOX_NAME] = "" )
    )

     

    • alhowarth's avatar
      alhowarth
      Helper I

      jdbuchanan71 

      Thanks for the suggestion, although I encountered a new error: The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression.

  • alhowarth , Try like

    calculate(count(MY_TABLE[JOB_NAME]), filter(MY_TABLE, MY_TABLE[JOB_TYPE] ="98" && not(isblank(MY_TABLE[BOX_NAME])) ))