Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

COUNTIF in DAX - DATA TABLE

Hi all,


I would like to know how to do a COUNTIF on DAX, something like the example below:

=COUNTIF(A:A,A2)


I reached my results via MEASURE but I wanted to make it as a actual COLUMN into my TABLE

I had an issue long ago, was sorted via Power Query but now it is not working with the new Dataset, it is taking hours for few lines.
https://community.powerbi.com/t5/Desktop/CUMULATIVE-COUNT-OF-TIMES-THAT-A-UNIC-INFO-APPEAR/m-p/2184565

  • Hi,

    I am not sure how your data model looks like, but please check the below picture and the attached pbix file.

    It is for creating a new column.

     

     

    Desired outcome CC = 
    COUNTROWS( FILTER( Data, Data[UnicNumber] = EARLIER(Data[UnicNumber]) ) )

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    This looks clean, loved it, I  have never use EARLIER, I accidentaly found a solution too, but I loved the clean way you did it!

    Yours:

    Mine:



    Thank you for helping me, I accept yours as a better solution! 


     




  • Hi,

    I am not sure how your data model looks like, but please check the below picture and the attached pbix file.

    It is for creating a new column.

     

     

    Desired outcome CC = 
    COUNTROWS( FILTER( Data, Data[UnicNumber] = EARLIER(Data[UnicNumber]) ) )