Forum Discussion

Rune_'s avatar
Rune_
Frequent Visitor
5 years ago
Solved

Start date and end date

Hi  I have three columns.  Posting date, Job No_ and Job Task No_   I would like to make to extra columns with start date and end date.    Start date would be List.Min of Posting date for speci...
  • Jimmy801's avatar
    5 years ago

    Hello Rune_ 

     

    group your data on you job-columns and add 3 functions.

    One all rows, one min on Posting date and one max on Posting date. Afterwards expand your AllRows-Column

    Here a example

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQMzDXMzIwtFDSAXIMzEG0gaFSrA5Qzhi3nIEleXJ47RsscrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Posting Date" = _t, #"Job No_" = _t, #"Job Task No_" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Posting Date", type date}, {"Job No_", Int64.Type}, {"Job Task No_", Int64.Type}},"de-DE"),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Job No_", "Job Task No_"}, {{"AllRows", each _, type table [Posting Date=date, Job No_=number, Job Task No_=number]}, {"Start Date", each List.Min([Posting Date]), type date}, {"End Date", each List.Max([Posting Date]), type date}}),
        #"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"Posting Date"}, {"Posting Date"})
    in
        #"Expanded AllRows"

     

    Copy paste this code to the advanced editor in a new blank query to see how the solution works.

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy