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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Jorgast
Resolver II
Resolver II

Finding Max value in a group

Hi Everyone,

 

I am trying to run sales data and determine who got credit for the sale based on the date. I want to put this in a table to show where the originating agent and the final sales agent are not the same person. The issue i am running into that i only have a date stamp and not date/time. How can i do a comparison of the data if i group by the customer name? I would also like to show the Adjusted Sale Amount for each agent in the comparison. I have tried to create a unique identifier by concatinating the columns but that didnt work.  Here is some dummy data to give you an idea of the data i am using. When the Sale amount = Adjusted amount that means this was a new customer and there were no adjustments to be made. 

 

Sale Agent NameSale Agent IDCustomer NameCityStateZipSale AmountAdjusted Sale AmountDate of sale
Bob1000Hulk ChicagoIL1234520020011/1/2017
John2000ThorAtlantaGA2345625025011/1/2017
Mary3000IronManNew YorkNY3456727527511/1/2017
Luke4000SpiderManQueensNY4567830030011/1/2017
Allen5000CaptainBrooklynNY5678932532511/1/2017
Carl6000HawkeyeSanFranCA6789035035011/1/2017
David7000FalconSeattleWA7890137537511/1/2017
         
Bob1000Hulk ChicagoIL1234520022511/5/2017
John2000ThorAtlantaGA2345625027511/6/2017
Mary3000IronManNew YorkNY3456727530011/6/2017
Luke4000SpiderManQueensNY4567830025011/8/2017
Allen5000CaptainBrooklynNY5678932550011/9/2017
Matt8000HawkeyeSanFranCA6789035032511/10/2017
Matt8000FalconSeattleWA7890137545011/11/2017
Matt8000IronManNew YorkNY3456730040011/12/2017
         
Bob1000SupermanHoustonTX1234520022511/5/2017
John2000Hulk ChicagoIL1234522530011/5/2017
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Jorgast

Create the following columns in your table.

Original agent = CALCULATE(FIRSTNONBLANK(Table[Sale Agent Name],""), FILTER(Table, Table[Customer Name]=EARLIER(Table[Customer Name]) && Table[Date of sale]<EARLIER(Table[Date of sale])))

checkcol = IF(Table[Original agent]<>BLANK() && Table[Sale Agent Name]<>Table[Original agent],1,0)

Then set the value of checkcol to 1 in visual level filters.
1.JPG



Regards,
Lydia

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Jorgast,

What is the result do you want to get based on the above sample data? Could you please post expected result in table format?

Regards,
Lydia

My ultimate goal is to be able to see those customers where the orginating sales agent and final sales agent are different. I would like to filter out those customers where the 1st sales agent and the last sales agent are the same.

 

 

Customer NameSale Agent NameSale AmountAdjusted Sale AmountDate of saleComment
FalconDavid37537511/1/2017Originating Sales Rep is different from final
FalconMatt37545011/11/2017Originating Sales Rep is different from final
HawkeyeCarl35035011/1/2017Originating Sales Rep is different from final
HawkeyeMatt35032511/10/2017Originating Sales Rep is different from final
Hulk Bob20020011/1/2017Originating Sales Rep is different from final
Hulk Bob20022511/5/2017Originating Sales Rep is different from final
Hulk John22530011/5/2017Originating Sales Rep is different from final
IronManMary27527511/1/2017Originating Sales Rep is different from final
IronManMary27530011/6/2017Originating Sales Rep is different from final
IronManMatt30040011/12/2017Originating Sales Rep is different from final
Anonymous
Not applicable

@Jorgast

Create the following columns in your table.

Original agent = CALCULATE(FIRSTNONBLANK(Table[Sale Agent Name],""), FILTER(Table, Table[Customer Name]=EARLIER(Table[Customer Name]) && Table[Date of sale]<EARLIER(Table[Date of sale])))

checkcol = IF(Table[Original agent]<>BLANK() && Table[Sale Agent Name]<>Table[Original agent],1,0)

Then set the value of checkcol to 1 in visual level filters.
1.JPG



Regards,
Lydia

@Anonymous

This is better than what i had i was thinking. Thanks

@Anonymous 

Would the code still work when the data is sorted in a different manner?

When i try using the First Non blank, it seems to be looking at the first non blank record in the data set, so everything is being compared to that.

 

Original agent = CALCULATE(FIRSTNONBLANK(Table[Sale Agent Name],""), FILTER(Table, Table[Customer Name]=EARLIER(Table[Customer Name]) && Table[Date of sale]<EARLIER(Table[Date of sale])))

 

 

Customer NameSale Agent NameSale AmountAdjusted Sale AmountDate of saleComment

FalconDavid37537511/1/2017Originating Sales Rep is different from final
HawkeyeCarl35035011/1/2017Originating Sales Rep is different from final
Hulk Bob20020011/1/2017Originating Sales Rep is different from final
IronManMary27527511/1/2017Originating Sales Rep is different from final
Hulk Bob20022511/5/2017 
Hulk John22530011/5/2017Originating Sales Rep is different from final
IronManMary27530011/6/2017Originating Sales Rep is different from final
HawkeyeMatt35032511/10/2017Originating Sales Rep is different from final
FalconMatt37545011/11/2017Originating Sales Rep is different from final
IronManMatt30040011/12/2017Originating Sales Rep is different from final

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors