Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Count distinct IDs based on another field

Hello,

 

I have a large data set where the ID is not distinct, and I want to create a measure to count the IDs per Region.

 

The table looks like this

IDRegion
001APAC
001APAC
002APAC
003AMER
003AMER
003AMER
004EU
005EU
005EU

 

And I want an output to be:

RegionIDs
APAC2
AMER1
EU2

 

The reason for this has to do with the filter pane. When I put Region in the filter pane, I want the number of rows count to be by the number of IDs, not by the number of rows for the region in the data set. So, I want the filter to read as the output (2nd table) above, but right now it reads like this:

RegionCount
APAC3
AMER3
EU3
  • Hi Anonymous ,

     

    Please create a new column:

    Count = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[Region] = EARLIER('Table'[Region])))

     

    Create a table visual:

     

    Best regards,

    Yadong Fang

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

2 Replies

  • Hi,

    To your table visual, drag Region and write this measure

    Measure = distinctcount(Data[ID])

    Hope this helps.

  • v-yadongf-msft's avatar
    v-yadongf-msft
    Community Support

    Hi Anonymous ,

     

    Please create a new column:

    Count = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[Region] = EARLIER('Table'[Region])))

     

    Create a table visual:

     

    Best regards,

    Yadong Fang

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