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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.