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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
prakash11440278
Post Prodigy
Post Prodigy

Latest Date records in direct query table

Hi All,

I want latest date records in my table. How can i restrict the data using latest date in my table. I am using direct query connection which i want to do the changes in power query instaed of dax. Please help.

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

Hi, @prakash11440278 

If you just want to keep the latest date records in PowerQuery, you need apply date filter to your date column.

veasonfmsft_0-1667972366714.png

If you  just want to keep most recent record base on categort , please refer to below tutorial.

Keep most recent record on a table with Power Query 

Sample M code:

 

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

 

Best Regards,
Community Support Team _ Eason

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @prakash11440278 

If you just want to keep the latest date records in PowerQuery, you need apply date filter to your date column.

veasonfmsft_0-1667972366714.png

If you  just want to keep most recent record base on categort , please refer to below tutorial.

Keep most recent record on a table with Power Query 

Sample M code:

 

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

 

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@prakash11440278 ,

 

Measure =

Var _max = maxx(allselected(Table), Table[Date])

return

calculate(countrows(Table), filter (Table, Table[Date] =_max))

 

Use these type of measure in visual or use it as visual level filter

 

If the latest is based on the category

 

https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors