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
MDO
Frequent Visitor

How to make a new column with latest data

Hi,

 

I want to make a new column for showing the latest bin code for each serial no - I cannot figure it out how to do it.

I have tried Group By in Power Query, but doesn't work.

 

I want something like below. The first 4 column are raw data, and the last are the data I need. 

Registering DateQuantitySerial No_Bin CodeLATEST BIN CODE
26-09-2023 00:001SN00001430601RENT-0253
26-10-2023 00:00-1SN000014TRANSITRENT-0253
27-09-2023 00:00-1SN00001430601RENT-0253
27-09-2023 00:001SN000014RENTALRENT-0253
26-10-2023 00:001SN000014RENT-0253RENT-0253
13-03-2023 00:00-1SN166TRANSITRENT-0188
03-02-2023 00:001SN166TRANSIT-REPRENT-0188
06-02-2023 00:00-1SN166TRANSIT-REPRENT-0188
06-02-2023 00:001SN166RENT-0188RENT-0188
27-02-2023 00:00-1SN166RENT-0188RENT-0188
13-03-2023 00:001SN0032970311RENT-0226
04-07-2023 00:001SN0032930601RENT-0226
13-06-2023 00:00-1SN0032970311RENT-0226
23-06-2023 00:00-1SN0032930601RENT-0226
23-06-2023 00:001SN0032911024RENT-0226
13-06-2023 00:001SN00329RENT-0226RENT-0226
04-07-2023 00:00-1SN00329RENT-0226RENT-0226
13-03-2023 00:001SN003657031111023
07-07-2023 00:00-1SN003657031111023
07-07-2023 00:001SN003651102311023
28-11-2022 00:00-1SN753TRANSITTRANSIT
15-02-2023 00:00-1SN753TRANSITTRANSIT
22-12-2022 00:001SN75321413TRANSIT
04-01-2023 00:00-1SN753TRANSITTRANSIT

 

 

I hope someone can help me 🙂 - Thank you in advance.

2 ACCEPTED SOLUTIONS
Kishore_KVN
Super User
Super User

Hello @MDO ,
Please find attached file for your reference. But the output is not mentioned correctly as per your example because for serial number SN166 latest date is 13th March so the Latest Bin Code will be TRANSIT not RENT-0188. So these things are taken care in the attached eample. 
DAX will be:

Latest Bin Calculated = 
Var One = CALCULATE(MAX('Table'[Registering Date]),ALLEXCEPT('Table','Table'[Serial No_]))
Var Result = CALCULATE(MAX('Table'[Bin Code]),FILTER('Table','Table'[Registering Date] = One))
Return
Result

 Output looks as below:

Kishore_KVN_0-1702882404302.png

 

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

 

View solution in original post

ThxAlot
Super User
Super User

Add an index column to differentiate codes registered on the same day.

ThxAlot_0-1702886395166.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

4 REPLIES 4
ThxAlot
Super User
Super User

Add an index column to differentiate codes registered on the same day.

ThxAlot_0-1702886395166.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Ahmedx
Super User
Super User

you wrote what you need
like this
09/26/2023 00:00 1 SN000014 30601 RENT-0253

Ahmedx
Super User
Super User

pls try this

Screenshot_1.png

Kishore_KVN
Super User
Super User

Hello @MDO ,
Please find attached file for your reference. But the output is not mentioned correctly as per your example because for serial number SN166 latest date is 13th March so the Latest Bin Code will be TRANSIT not RENT-0188. So these things are taken care in the attached eample. 
DAX will be:

Latest Bin Calculated = 
Var One = CALCULATE(MAX('Table'[Registering Date]),ALLEXCEPT('Table','Table'[Serial No_]))
Var Result = CALCULATE(MAX('Table'[Bin Code]),FILTER('Table','Table'[Registering Date] = One))
Return
Result

 Output looks as below:

Kishore_KVN_0-1702882404302.png

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly. 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.