Search code examples
powerbidata-visualizationdaxbusiness-intelligence

DAX measure to count duplicates?


I'm looking for some guidance on how to structure a DAX measure that will count whether a row is a duplicate.

To be counted as a duplicate, the combination of the two columns named: Latitude & Longitude need to be identical. The customers are distinct here.

How would I create a DAX measure called occurrence in Power BI to capture that?

Customer Latitude Longitude Occurance
C1 25.2318994 89.0194663 3
C2 25.2318994 89.0194663 3
C3 22.8698924 89.0379756 2
C4 25.2318994 89.0194663 3
C5 22.8698924 89.0379756 2
C6 23.2740535 88.0194665 1

Solution

  • Occurence = 
        RANKX(
            FILTER(
                    'Table',
                    'Table'[Latitude]=EARLIER('Table'[Latitude]) &&  'Table'[Longitude]=EARLIER('Table'[Longitude])
                    ),
            'Table'[Customer], , DESC
            )