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
RDF25087
Helper I
Helper I

Add latest date by item to data

Hello!

 

Another day, another Power BI issue...

 

I have a dataset consisting of a unique list of customers, something like this:

Contract IDCustomer NameSales PersonPost Code Area
1234Customer ATim JonesBS
1235Customer BTim JonesTA
1236Customer CTim JonesEX
1237Customer DSarah RobertsWA
1238Customer ATim JonesBS
1239Customer ATim JonesBS
1240Customer DSarah RobertsWA
1241Customer ESarah RobertsSY
1242Customer BTim JonesTA
1243Customer ESarah RobertsSY
1244Customer DSarah RobertsWA
1245Customer FSarah RobertsCW

 

 

I also have a list of product sales by some (but not all of the above customers). In some instances a customer may have made multiple purchases. So, the sales history table would look something like this:

PURCHASE HISTORY
Contract IDProductPurchase Date
1237Product A03/01/2023
1244Product C03/01/2023
1244Product A09/01/2023
1235Product B15/01/2023
1235Product A23/02/2023
1235Product B24/02/2023
1234Product A08/03/2023
1242Product B01/04/2023
1242Product C01/04/2023
1245Product C22/03/2023
1245Product A25/03/2023
1245Product A25/03/2023
1245Product A03/04/2023
1240Product B30/01/2023

 

I need to either add a column to the customers list stating the last purchase date, e.g...

 

Contract IDCustomer NameSales PersonPost Code AreaLast Purchase
1234Customer ATim JonesBS08/03/2023
1235Customer BTim JonesTA24/02/2023
1236Customer CTim JonesEXNULL
1237Customer DSarah RobertsWA03/01/2023
1238Customer ATim JonesBSNULL
1239Customer ATim JonesBSNULL
1240Customer DSarah RobertsWA30/01/2023
1241Customer ESarah RobertsSYNULL
1242Customer BTim JonesTA01/04/2023
1243Customer ESarah RobertsSYNULL
1244Customer DSarah RobertsWA09/01/2023
1245Customer FSarah RobertsCW03/04/2023

 

Or to create a new measure that will do the same thing.

 

Ultimately, I'm looking to map a sales persons customers and colour code them according to whether they've made a purchase or not.

 

Any help, as always would be greatly appreciated.

 

Thanks

RDF

1 ACCEPTED SOLUTION
bhelou
Responsive Resident
Responsive Resident

Dear , 

In power Query do the same as follow : 

1 - Group list 2 by max date 
2 - Merge Queries in list 1 with list 2 
3- Expand List 2 , it will show up the max date that match with the contract ID 

Attached Images and Attached PBIX file link 

https://www.dropbox.com/s/e13zbo13scm5myt/Max%20Date.pbix?dl=0 

Regards , 

Kindly accept as a solution and a kudo is appreciated . 

List 2 OriginalList 2 OriginalGroup By Max DateGroup By Max DateList 1 OriginalList 1 OriginalMerge  list 1 and 2 ,Merge list 1 and 2 ,Expand max dateExpand max dateReportReport


View solution in original post

2 REPLIES 2
RDF25087
Helper I
Helper I

@bhelou  - thank you for your solution, and especially for the step-by-step images - they were especially useful for a beginner like myself.

 

I got a little confused about how to Expand the column. After the merge I had a column in my data displaying "table". After a little more googling, I realised I simply had to click on the double-arrow icon in the column header and select the column I wanted to bring in/expand. Hope that helps any other newbie like myself that need everything spelt out for them!

 

Regards

RDF

bhelou
Responsive Resident
Responsive Resident

Dear , 

In power Query do the same as follow : 

1 - Group list 2 by max date 
2 - Merge Queries in list 1 with list 2 
3- Expand List 2 , it will show up the max date that match with the contract ID 

Attached Images and Attached PBIX file link 

https://www.dropbox.com/s/e13zbo13scm5myt/Max%20Date.pbix?dl=0 

Regards , 

Kindly accept as a solution and a kudo is appreciated . 

List 2 OriginalList 2 OriginalGroup By Max DateGroup By Max DateList 1 OriginalList 1 OriginalMerge  list 1 and 2 ,Merge list 1 and 2 ,Expand max dateExpand max dateReportReport


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.