locked
DAX Count and Sum functions with condition RRS feed

  • Question

  • Hi,

     Can you please help me on DAX Count function with Condition

    Exp: I have a column1, Column2 in Table TableA

    I want to count on Column1 based on the condition Column2=1

    Like =COUNT(Column1) WHERE Column2=1

    If you know please share the formula

    Thanks in Advance

    Thank You,

    Grace


    Thursday, June 6, 2013 10:28 PM

Answers

  • Hi Grace -

    You should be able to use CALCULATE with a filter argument like this:

    =CALCULATE(COUNT(YourTable[Column1]),YourTable[Column2] = 1)
    Let me know if that helps.

    Brent Greenwood, MS, MCITP, CBIP // Please mark correct answers and helpful posts // http://brentgreenwood.blogspot.com

    Friday, June 7, 2013 12:39 AM
    Answerer

All replies

  • Hi Grace -

    You should be able to use CALCULATE with a filter argument like this:

    =CALCULATE(COUNT(YourTable[Column1]),YourTable[Column2] = 1)
    Let me know if that helps.

    Brent Greenwood, MS, MCITP, CBIP // Please mark correct answers and helpful posts // http://brentgreenwood.blogspot.com

    Friday, June 7, 2013 12:39 AM
    Answerer
  • Can you do the same for distinct count ?
    Thursday, July 24, 2014 5:48 PM
  • CALCULATE( <expression>, <filter expression> ) is a very powerful and basic building block in DAX. If you replaced the COUNT() with a DISTINCTCOUNT(), it would work just fine.

    Here's an intro to DAX's CALCULATE()

    Thursday, July 24, 2014 7:21 PM
  • Thanks Greg
    Thursday, July 24, 2014 7:28 PM