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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
VModani
Frequent Visitor

How to avoid double counting when an item links to multiple items in a different column

I have data that among other things contains names and Offer/Reject action. I want to find how many names are in each action Reject or Accept. I can create 2 seperate measures for both actions and do distinctcount to count each individually. But that results in some doublecounting as some name are first reject and then offered so are counted seperately. 

 

I want to count them seperately only but need to remove if they were in the other action before.

 

Take John as an example below. He appears 4 times, 2 reject and 2 offered. I created a measure of Distinctcount and filtered by action. so I get 1 in offer and 1 in reject. I only want 1, based on the newest entry.

 

Thanks!!

 

DateNameAction
1 FebJohnReject
1 FebJohnReject
2 FebAdamReject
2 FebRobertOffer
3 FebJohnOffer 
4 FebMikeReject
4 FebMikeOffer
5 FebJohnOffer

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, 

I am not quite sure which action does Mike belong to. On the same day, Mike's result is Reject and Offer.

I guess Mike belongs to both, and the below calculation shows like this.

 

Please check the attached pbix file.

 

Picture1.png

 

Distinctcount name by last action only: =
IF (
HASONEVALUE ( Data[Action] ),
CALCULATE (
COUNTROWS ( Data ),
TREATAS (
GROUPBY (
ALL ( Data ),
Data[Name],
"@lastactiondate", MAXX ( CURRENTGROUP (), Data[Date] )
),
Data[Name],
Data[Date]
)
)
)
 

 

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.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, 

I am not quite sure which action does Mike belong to. On the same day, Mike's result is Reject and Offer.

I guess Mike belongs to both, and the below calculation shows like this.

 

Please check the attached pbix file.

 

Picture1.png

 

Distinctcount name by last action only: =
IF (
HASONEVALUE ( Data[Action] ),
CALCULATE (
COUNTROWS ( Data ),
TREATAS (
GROUPBY (
ALL ( Data ),
Data[Name],
"@lastactiondate", MAXX ( CURRENTGROUP (), Data[Date] )
),
Data[Name],
Data[Date]
)
)
)
 

 

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.


Go to My LinkedIn Page


Sorry for not making the sample properly. Mike belongs to the Offered action. I think date/time datatype can solve that. The solution itself if working. Thank You!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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