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

Day with latest time

Hello, 

I have this table. I want to have items with date and latest time. See example.

Any idea how to do it?

ItemDateAmount
A1.3.2023 15:031
A1.3.2023 9:318
A1.3.2023 6:004
A25.2.2023 7:555
A25.2.2023 6:043
B15.2.2023 16:117
B15.2.2023 11:003
B15.2.2023 15:001
C9.2.2023 12:235
C9.2.2023 9:563

 

=>

 

ItemDateAmount
A1.3.2023 15:031
A25.2.2023 7:555
B15.2.2023 16:117
C9.2.2023 12:235
2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7NDcAgCAbQVRrPxgiIVm5txzDuv0axJCZtvcH3wk9r7nDeQaCAEWkDlkgjcN1/qAqB9vtfssSofZqCHNCoCLMGvCCdShrQQ+fYNwmywLhVVgZ2bTnHZvb9pVWdhII0P3lRFc62sN8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Date = _t, Amount = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"Date", type datetime}, {"Amount", Int64.Type}}),

    #"Added Dt" = Table.AddColumn(#"Changed Type", "Dt", each Date.From([Date])),
    Grouped = Table.Group(#"Added Dt", "Dt", {"Grp", each Table.Max(_, "Date")}, 0),
    #"Expanded Grp" = Table.RemoveColumns(Table.ExpandRecordColumn(Grouped, "Grp", {"Item", "Date", "Amount"}), "Dt")
in
    #"Expanded Grp"

 

CNENFRNL_0-1677914550356.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

wdx223_Daniel
Super User
Super User

NewStep=Table.FromRecords(Table.Group(PreviousStepName,"Item",{"n",each Table.Sort(_,{"Date",1}){0}})[n])

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.

Top Solution Authors
Top Kudoed Authors