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
Anonymous
Not applicable

Transform data only most recent

Hi all, how do I use Query Editor to filter out the records with the old date? For example, with Ticket ID 12 and 14 I only want to keep the record with the most recent date (9/21/20 for Ticket 12, 9/25/20 for Ticket 14). Thanks!

 

Current Table

Ticket IDDateStatus
129/20/20Open
129/21/20Closed
149/24/20Open
149/25/20Open

Desired Table

Ticket IDDateStatus
129/21/20Closed
149/25/20Open
1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create a measure as below:

Day = 
var _latestday=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[Ticket ID]=MAX('Table'[Ticket ID])))
Return
IF(MAX('Table'[Date])=_latestday,MAX('Table'[Date]),BLANK())

Or a calculated column as below:

Column = 
var _latestday=CALCULATE(MAX('Table'[Date]),FILTER('Table','Table'[Ticket ID]=EARLIER('Table'[Ticket ID])))
Return
IF('Table'[Date]=_latestday,'Table'[Date],BLANK())

And you will see:

Screenshot 2020-10-05 165216.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create a measure as below:

Day = 
var _latestday=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[Ticket ID]=MAX('Table'[Ticket ID])))
Return
IF(MAX('Table'[Date])=_latestday,MAX('Table'[Date]),BLANK())

Or a calculated column as below:

Column = 
var _latestday=CALCULATE(MAX('Table'[Date]),FILTER('Table','Table'[Ticket ID]=EARLIER('Table'[Ticket ID])))
Return
IF('Table'[Date]=_latestday,'Table'[Date],BLANK())

And you will see:

Screenshot 2020-10-05 165216.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

@amitchandak @Greg_Deckler any ideas on this?

CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , you might want to try this solution,

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRS0lGy1DcyACIgy78gNU8pVgchbggRd87JL05NgciYQGRM0HVAxU2RxWMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Ticket ID" = _t, Date = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ticket ID", Int64.Type}, {"Date", type date}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Ticket ID"}, {{"Latest", each _{[Date = List.Max([Date])]}}}),
    #"Expanded Latest" = Table.ExpandRecordColumn(#"Grouped Rows", "Latest", {"Date", "Status"}, {"Date", "Status"})
in
    #"Expanded Latest"

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!

darentengmfs
Post Prodigy
Post Prodigy

Hi @Anonymous 

 

Please take a look at the following article:

 

https://community.powerbi.com/t5/Desktop/Latest-Date-Filter/td-p/556579

 

You might have to change some of the parameters to suit your dataset.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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