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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
NavaneethArra
Regular Visitor

how to get Max Date for each month in power query editor

I have a list of dates for each month 

for example 
Date                     Value 
01/Jan/2023          15
12/Jan/2023           25
25/Jan/2023           37
01/Feb/2023          48
15/Feb/2023          51
28/Feb/2023          57 
06/Mar/2023          64
10/Mar/2023          68
31/Mar/2023          74
01/Apr/2023           83
18/Apr/2023           90
26/Apr/2023           87 
07/May/2023          87
24/May/2023          104


I wanted to have a table with only Max date for each particular month  in power query editor


1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xc29CoUwDIbhe8ksNEl/HV0cBK+gOCi4ipzNu7cYe0hdH/LmyxmQzLQehpEtdEAeli4DsUYWZK/RxgdLPu5bRZck9xo9SZ4afPNg5vVXMTjJsUH5aUljdHV9OP+YrORJY4+yHprLdz2Wn9cH2WkkLEvLDQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Year-Month", each Date.EndOfMonth([Date])),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Year-Month"}, {{"Count", (x)=> Table.FromRecords({ Table.Max(x,"Date")})}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Count"}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Removed Other Columns", "Count", {"Date", "Value"}, {"Date", "Value"})
in
    #"Expanded Count"

View solution in original post

1 REPLY 1
Ahmedx
Super User
Super User

pls try this

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xc29CoUwDIbhe8ksNEl/HV0cBK+gOCi4ipzNu7cYe0hdH/LmyxmQzLQehpEtdEAeli4DsUYWZK/RxgdLPu5bRZck9xo9SZ4afPNg5vVXMTjJsUH5aUljdHV9OP+YrORJY4+yHprLdz2Wn9cH2WkkLEvLDQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Year-Month", each Date.EndOfMonth([Date])),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Year-Month"}, {{"Count", (x)=> Table.FromRecords({ Table.Max(x,"Date")})}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Count"}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Removed Other Columns", "Count", {"Date", "Value"}, {"Date", "Value"})
in
    #"Expanded Count"

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.