Forum Discussion

AllanBerces's avatar
AllanBerces
Icon for Post Prodigy rankPost Prodigy
7 months ago
Solved

Min or Early Start Date

Hi good day, can anyone help me to create new table from my exisitng table but only column Job and Date, but date only the start date.  DESIRED OUTPUT Job Group Trade Hours Per da...
  • FreemanZ's avatar
    7 months ago

    hi AllanBerces ,

     

    You can write a calculated table like:

    Table = 
    ADDCOLUMNS(
        VALUES(Table1[Job]),
        "Early Start",
        CALCULATE(MIN(Table1[Date]))
    )

     

    it works like:

  • FreemanZ's avatar
    FreemanZ
    7 months ago

    If you have a big table, it would be more advisible to do it with Power Query, like:

    M code:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ldMxC8IwEAXg/9K5pLlccklnLVSKqLUiQZxEUBRHf78RkRRuyWV5yzc83pHTqdodO0ivqqtjt59SrK+XWwpAFSiladrGaEPVuS7BoEUasu7GyTpylrgnpV1KbJyMU+b9FJdMph5eBn0pDBke4hinVBR5U6sssNmKPAi9EXoUepv9Ko49GLSZL+7v+/PrQBl2mRLuZXw2/hA78sER561CNn2BBpE2Io0ibUXaiTSJ9Pw8w+b1COS5JgW/Ty/Ts1tuh+1mrUOrOUflfxxl3Mr4f8TzBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Job = _t, Group = _t, Trade = _t, #"Hours Per day" = _t, Date = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Job", type text}, {"Group", type text}, {"Trade", type text}, {"Hours Per day", type number}, {"Date", type date}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Job"}, {{"EarlyStart", each List.Min([Date]), type nullable date}})
    in
        #"Grouped Rows"

     

  • Ashish_Mathur's avatar
    7 months ago

    HI,

    This M code in Power Query works

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Grouped Rows" = Table.Group(Source, {"Job"}, {{"Count", each Table.Min(_,"Date")}}),
        #"Expanded Count" = Table.ExpandRecordColumn(#"Grouped Rows", "Count", {"Group", "Trade", "Hours Per day", "Date"}, {"Group", "Trade", "Hours Per day", "Date"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Count",{{"Job", type text}, {"Group", type text}, {"Trade", type text}, {"Hours Per day", type number}, {"Date", type date}})
    in
        #"Changed Type1"

    Hope this helps.

     

  • cengizhanarslan's avatar
    7 months ago

    In Power Query:

    1. Transform data → Power Query
    2. Select your table
    3. Keep only Job and Date 
    4. Home ➜ Group By
    • Group by: Job
    • New column name: Start Date
    • Operation: Min

     

    However, if your table is big as you say I would suggest make these aggregations upstream like in SQL as it would be more effective in terms of performans and capacity usage.