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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
MPICKETT
Frequent Visitor

Identify Duplicate with the Highest Value

Hello All -

I am attempting to use a calculated column to identify the duplicate rows with the highest value. I know how to do this in Excel, using the COUNTIFS function, however, I have been struggling to do this in DAX/Power BI.

My sample data looks like,Driver by Week and Mgr Stop Count.JPG

In another column, I would like to identify the rows that are the duplicates, based on Year.Wk, DriverName, with the highest value in Stops per Week.

The result would look as follows,

Driver by Week and Mgr Stop Count 2.JPG

Currently, I have the following Calculated Column, which is providing the wrong answer;

 
Driver Choice = CALCULATE (
COUNTROWS('Driver Relationship Table'),
FILTER (
'Driver Relationship Table',
'Driver Relationship Table'[Year.Wk] = EARLIER('Driver Relationship Table'[Year.Wk]) &&
'Driver Relationship Table'[DriverName] = EARLIER('Driver Relationship Table'[DriverName])&&
'Driver Relationship Table'[Num of Services] = CALCULATE(MAX('Driver Relationship Table'[Max Stops for Week & Driver]),FILTER('Driver Relationship Table','Driver Relationship Table'[Year.Wk]=EARLIER('Driver Relationship Table'[Year.Wk]) && 'Driver Relationship Table'[DriverName]=EARLIER('Driver Relationship Table'[DriverName])))
)
)
 
Any assistance on this would be helpful.
Thank you!
1 ACCEPTED SOLUTION
BekahLoSurdo
Resolver IV
Resolver IV

Hi @MPICKETT,

 

Would this work?

 

Driver Choice = IF ( 
	CALCULATE ( 
		MAX ( 'Driver Relationship Table'[Stops per Week] ), 
		ALLEXCEPT ( 'Driver Relationship Table', 'Driver Relationship Table'[Year.Wk], 'Driver Relationship Table'[DriverName] )
	) = 'Driver Relationship Table'[Stops per Week], 
	1, 
	0
)

Best,

Bekah

View solution in original post

3 REPLIES 3
Yenolmedo10
Regular Visitor

how is this done in excel?

BekahLoSurdo
Resolver IV
Resolver IV

Hi @MPICKETT,

 

Would this work?

 

Driver Choice = IF ( 
	CALCULATE ( 
		MAX ( 'Driver Relationship Table'[Stops per Week] ), 
		ALLEXCEPT ( 'Driver Relationship Table', 'Driver Relationship Table'[Year.Wk], 'Driver Relationship Table'[DriverName] )
	) = 'Driver Relationship Table'[Stops per Week], 
	1, 
	0
)

Best,

Bekah

I knew I was overcomplicating things. That did the trick!

Thank you so much Bekah!

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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