Forum Discussion

Danielwood's avatar
Danielwood
Helper I
2 years ago
Solved

How to write DAX countif

Hi, my data table has lots of static information, but I want to do some countif functions to make reporting easier. I've tried using a text box, then values, and typing out the question but it's very...
  • Ritaf1983's avatar
    2 years ago

    Hi Danielwood 
    You can use a dax measure :

    count_sold_delivered =
    CALCULATE(DISTINCTCOUNT('Table'[product name]),'Table'[sold]="Y" &&'Table'[status]="delivered")

    Pbix is attached

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Hi Danielwood 
    You can use one of the functions that I mentioned in my previous response.

    For example :

    count_sold_delivered =
    CALCULATE(DISTINCTCOUNT('Table'[product name]),'Table'[sold]="Y" &&SEARCH("deli",'Table'[status],,0)<>0)
    The updated pbix is attached 
    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Danielwood 

    1. add 0 to the measure :

    count_sold_delivered =
    CALCULATE(DISTINCTCOUNT('Table'[product name]),'Table'[sold]="Y" &&SEARCH("bla bla bla",'Table'[status],,0)<>0)+0

    2. The same but you need "= 0" 

    count_sold_delivered =
    CALCULATE(DISTINCTCOUNT('Table'[product name]),'Table'[sold]="Y" &&SEARCH("shiped",'Table'[status],,0)=0)

    The updated pbix is attached again 🙂
    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly