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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
vjnvinod
Impactful Individual
Impactful Individual

How to remove duplicate from measure

hi Team,

 

I am using a function countrows to get the count details of the regions, however i  don't want the duplicate to be counted 2 or 3 times based on their repetition

for instance if Canada is repeating 3 times, it should only count as 1 

how do i remove the duplicate?

can someone help me with the measure?

 

Capture.PNG

1 ACCEPTED SOLUTION
nandic
Super User
Super User

@vjnvinod ,
Countrows function returns count of rows per criteria.
If there are 3 rows for Canada, it will return value 3.
On the other hand, if you would like to count have many distinct items(for example) were sold in Canada, they you should write measure like this:

DistinctCount = DISTINCTCOUNT('Item'[Item Id])

Furthermore, if you are using list or matrix, it will give you unique combinations of data (unique combinations of country/region) so there should be no duplicate rows on visualization.

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @vjnvinod 

Based on your description, I created data to reproduc your scenario. The pbix file is attached in the end.

MSL:

c1.png

 

You may create a measure as below.

Count = 
COUNTROWS(
    DISTINCT(MSL[Region])
)

 

Result:

c2.png

 

Best Regards

Allan

 

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

 

 

 

Greg_Deckler
Super User
Super User

@vjnvinod - Use DISTINCTCOUNT or maybe COUNTROWS(DISTINCT(...))

 

https://docs.microsoft.com/en-us/dax/distinctcount-function-dax



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Pragati11
Super User
Super User

HI @vjnvinod ,

 

 

Use DISTINCTCOUNT to count unique rows for a column rather than using COUNTROWS or you can use DISTINCT with COUNTROWS.

 

UniqueCount = DISTINCTCOUNT(tablename[column])

 

OR

 

UniqueCount = COUNTROWS(DISTINCT(tablename[column]))

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

nandic
Super User
Super User

@vjnvinod ,
Countrows function returns count of rows per criteria.
If there are 3 rows for Canada, it will return value 3.
On the other hand, if you would like to count have many distinct items(for example) were sold in Canada, they you should write measure like this:

DistinctCount = DISTINCTCOUNT('Item'[Item Id])

Furthermore, if you are using list or matrix, it will give you unique combinations of data (unique combinations of country/region) so there should be no duplicate rows on visualization.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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