cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mb0307
Post Patron
Post Patron

PowerQuery - max date by product

Hi,

 

I need help with PowerQuery - thanks in advance.

 

I have a table below:

mb0307_0-1614122238937.png

 

I need to create a Custom Column in PowerQuery showing Max Date per Product.  

 

Result in same table:

mb0307_0-1614163966524.png

 

 

Thanks.

 

1 ACCEPTED SOLUTION
Rocco_sprmnt21
Super User II
Super User II

4 REPLIES 4
mb0307
Post Patron
Post Patron

@Rocco_sprmnt21  thanks.  

Rocco_sprmnt21
Super User II
Super User II

Vera_33
Solution Sage
Solution Sage

Hi @mb0307 

 

Have a try

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WMlTSUTIw1Dew1DcyMDJUitWBChlhChljCpmgCBkBhQwN9YEIVcgIU8gYU8gEIRQLAA==",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Product = _t, Date = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(
    Source,
    {{"Product", Int64.Type}, {"Date", type date}}
  ),
  #"Grouped Rows" = Table.Group(
    #"Changed Type",
    {"Product"},
    {{"Max", each List.Max([Date]), type nullable date}}
  ),
  #"Merged Queries" = Table.NestedJoin(
    #"Changed Type",
    {"Product"},
    #"Grouped Rows",
    {"Product"},
    "Grouped Rows",
    JoinKind.LeftOuter
  ),
  #"Expanded Grouped Rows" = Table.ExpandTableColumn(
    #"Merged Queries",
    "Grouped Rows",
    {"Max"},
    {"Max"}
  )
in
  #"Expanded Grouped Rows"

@Vera_33 

Thanks for your response but I am struggling to execute the query due to my limited knowledge.  Sorry about that.

 

I have updated the original post - basically I want result in same table.  Is it possible to do in Custom Column window?

 

Thanks.

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors