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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
EaglesTony
Helper V
Helper V

How do I get the latest record in the transform step

Hi,

 

  I have the following table coming in

 

Created                             Key

8/29/2023 6:42:28 PM      A

7/26/2023 5:22:58 PM      A

7/12/2023 9:00:01 AM      A

6/27/2023 6:56:33 PM      A

10/21/2023 7:52:22 PM    B

 

What I need is the latest record only, so it would end up being

Created                             Key

8/29/2023 6:42:28 PM      A

10/21/2023 7:52:22 PM    B

 

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @EaglesTony ,

 

You can also consider using Dax to solve this problem:

Create calculated table.

Table 2 =
FILTER(
    'Table',
    'Table'[Ceated]=
    MAXX(
        FILTER(ALL('Table'),'Table'[Key]=EARLIER('Table'[Key])),[Ceated]))

vyangliumsft_0-1699235021553.png

 

Best Regards,

Liu Yang

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

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Created", type datetime}, {"Key", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Key"}, {{"Count", each Table.Max(_,"Created")}}),
    #"Expanded Count1" = Table.ExpandRecordColumn(#"Grouped Rows", "Count", {"Created"}, {"Created"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Count1",{{"Key", type text}, {"Created", type datetime}})
in
    #"Changed Type1"

Hope this helps.

Ashish_Mathur_0-1699241846922.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yangliu-msft
Community Support
Community Support

Hi  @EaglesTony ,

 

You can also consider using Dax to solve this problem:

Create calculated table.

Table 2 =
FILTER(
    'Table',
    'Table'[Ceated]=
    MAXX(
        FILTER(ALL('Table'),'Table'[Key]=EARLIER('Table'[Key])),[Ceated]))

vyangliumsft_0-1699235021553.png

 

Best Regards,

Liu Yang

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

EaglesTony
Helper V
Helper V

I got it.

 

1) Sort the field Created Descending

2) Wrap it around Table.Buffer:

= Table.Buffer(
Table.Sort(#"Changed Type",{{"CREATED", Order.Descending}}))

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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