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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.