Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Count occurrence

Hello guys!

I wonder if there is a solution for the following. I want to count the number of occurence of each Product ID.

 

Input:

Product ID
B
B
B
C
C
D
D
D
D
D

 

Expected Output

Product ID Occurence
B3
C2
D5

 

Is there a way to achieve this through DAX?

Thank you!:)

  • Just drag your Product ID column into a table visual, and add this measure too.

     

    Occurence = COUNT(Table[Product ID])  //replace table with actual table name

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

  • Anonymous , on any visual plot this measure with product id

     

    countrows(table)

3 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Just drag your Product ID column into a table visual, and add this measure too.

     

    Occurence = COUNT(Table[Product ID])  //replace table with actual table name

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you this worked well!
      Do you also happen to know how I can calculate the average of a measure? I would like to calculate the average occurrence in my next step but this doesnt seem to work with average dax function.

  • Anonymous , on any visual plot this measure with product id

     

    countrows(table)