Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
alagator28
Helper II
Helper II

Counting distinct number of duplicate rows

I have a table where I have used a DAX formula to determine if a row is a "duplicate" by counting the number of occurrences. In this scenario, a duplicate is when the values of Fruit and Color in one row both match the values for Fruit and Color in another row.

 

Occurences =
VAR _CurrentFruit = 'Table1'[Fruit]
VAR _CurrentColor = 'Table1'[Color]
RETURN
    COUNTROWS(
        FILTER(
            'Table1',
            'Table1'[Fruit] = _CurrentFruit &&
             'Table1'[Color] = _CurrentColor
        )
    )
 
This works and tells me if it's a duplicate (any value over 1) and if a duplicate, how many duplicates of that same row exist.

 

Table1

FruitColorOccurences
AppleRed1
AppleGreen3
GrapePurple2
AppleGreen3
GrapeGreen1
AppleGreen3
GrapeYellow1
AppleYellow1
GrapePurple2

 

 
However, I would now like to know how many distinct duplicates there are. In this case there are 2 distinct repeating rows. How can I calculate this?
 
FruitColorOccurrences
AppleGreen3
GrapePurple2

 

Thanks in advance.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1728402974797.png

 

 

Expected table = 
	SUMMARIZE(
		FILTER(
			ADDCOLUMNS(
				Table1,
				"@occurences", VAR _CurrentFruit = 'Table1'[Fruit]
				VAR _CurrentColor = 'Table1'[Color]
				RETURN
					COUNTROWS(FILTER(
						'Table1',
						'Table1'[Fruit] = _CurrentFruit &&
						'Table1'[Color] = _CurrentColor
					)
					)
			),
			[@occurences] > 1
		),
		Table1[Fruit],
		Table1[Color],
		[@occurences]
	)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1728402974797.png

 

 

Expected table = 
	SUMMARIZE(
		FILTER(
			ADDCOLUMNS(
				Table1,
				"@occurences", VAR _CurrentFruit = 'Table1'[Fruit]
				VAR _CurrentColor = 'Table1'[Color]
				RETURN
					COUNTROWS(FILTER(
						'Table1',
						'Table1'[Fruit] = _CurrentFruit &&
						'Table1'[Color] = _CurrentColor
					)
					)
			),
			[@occurences] > 1
		),
		Table1[Fruit],
		Table1[Color],
		[@occurences]
	)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you @Jihwan_Kim ! It seems to provide the correct answer for me, but I want to be sure I applied it as you intended. I created a new measure and used this to get "2" as my value. As it's my first time using "Summarize", it's new to me. It's interesting to see that I can generate a virtual table, I didn't know about this functionality.

# Distinct Duplicates = 

VAR _Table =	SUMMARIZE(
		FILTER(
			ADDCOLUMNS(
				Table1,
				"@occurences", VAR _CurrentFruit = 'Table1'[Fruit]
				VAR _CurrentColor = 'Table1'[Color]
				RETURN
					COUNTROWS(FILTER(
						'Table1',
						'Table1'[Fruit] = _CurrentFruit &&
						'Table1'[Color] = _CurrentColor
					)
					)
			),
			[@occurences] > 1
		),
		Table1[Fruit],
		Table1[Color],
		[@occurences]
	)

RETURN COUNTROWS(_Table)

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.