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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

How to count in Power BI without duplicates by several conditions?

Hello, Power BI WiZards!

I broke my mind to make a report that can count by several conditions exclude duplicates. 

In my case i have data with date and other information. And i need to check by condition and count unique condition no metter in which date it happens.

My results i need to have by date. I could make something like this with distinctcount, but it count well only Grand total not the result by day. I need to count duplicate only in first date when it happen and never count in another days.

In this case i count by "passed" and also check other columns for duplicate.

I hope u could help me... I waste like 5 hours to find a solution but i couldnt. I hope you could understand me well.ironmind1000_0-1653489613280.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I suggest you to create a virtual table in your measure to calculate the result.

My Sample:

RicoZhou_0-1654071980785.png

Measure:

Measure = 
VAR _BASIC = ADDCOLUMNS(FILTER('Table','Table'[Approved]<>BLANK()&&'Table'[Status]<>BLANK()),"Earliest",CALCULATE(MIN('Table'[Date]),ALLEXCEPT('Table','Table'[State],'Table'[Approved],'Table'[Status])))
VAR _FILTER = FILTER(_BASIC,[Date] = [Earliest])
RETURN
COUNTX(_FILTER,[State])+0

Result is as below.

RicoZhou_1-1654071994876.png

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

TY, but it doesnt fit in my case... =(
Let me show you on real example. In this real case i have 2 dates, where data for May 22 contain data for 22 and 23 but with changed date to 22. In total i want to see this 15046on 22 and 0 on 23, coz we already count this for 22 and 23 it is all duplicates. I create this example especially to find a way discount this duplicates and count only unique examples...

ironmind1000_0-1653497014804.png

 

 

Hi @Anonymous ,

 

I suggest you to create a virtual table in your measure to calculate the result.

My Sample:

RicoZhou_0-1654071980785.png

Measure:

Measure = 
VAR _BASIC = ADDCOLUMNS(FILTER('Table','Table'[Approved]<>BLANK()&&'Table'[Status]<>BLANK()),"Earliest",CALCULATE(MIN('Table'[Date]),ALLEXCEPT('Table','Table'[State],'Table'[Approved],'Table'[Status])))
VAR _FILTER = FILTER(_BASIC,[Date] = [Earliest])
RETURN
COUNTX(_FILTER,[State])+0

Result is as below.

RicoZhou_1-1654071994876.png

 

Best Regards,
Rico Zhou

 

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

 

jcalheir
Solution Supplier
Solution Supplier

Hi,

 

Not sure if i understood fully your problem, but if you want to count distinct values by multiple indexes, you can do the following:

 

Create a new column concatenating the index values you want to check for distincts, ex:

DistinctID = Table[Aproved] &"-"& Table[Status] 

This should give you a new column with the following format "passed-Complete"

 

Then you can create a DAX formula with distinctcount on this new column.

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

 

 

mh2587
Super User
Super User

Counting(Measure) = CALCULATE(COUNT(TableName[Date]),TableName[Approved]="Passed")

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.