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

JobGroupTradeHours Per dayDate
QWE1111WESTMech13.862/9/2026
QWE1111WESTMech13.862/10/2026
QWE1111WESTMech13.862/11/2026
ERT456546WESTMech16.053/5/2026
ERT456546WESTMech16.053/6/2026
HTYDWESTMech3.873/6/2026
HTYDWESTMech3.873/7/2026
HTYDWESTMech3.873/8/2026
UYRYT5463WESTMech14.412/10/2026
UYRYT5463WESTMech14.412/11/2026
UYRYT5463WESTMech14.412/12/2026
UYRYT5463WESTMech14.412/13/2026
UYRYT5463WESTMech14.412/14/2026
IYRH1234WESTCivil21.253/6/2026
IYRH1234WESTCivil21.253/7/2026
IYRH1234WESTCivil21.253/8/2026
KYE67856WESTCivil9.32/10/2026
KYE67856WESTCivil9.32/11/2026
KYE67856WESTCivil9.32/12/2026
KYE67856WESTCivil9.32/13/2026
KYE67856WESTCivil9.32/14/2026
KYE67856WESTCivil9.32/15/2026
KYE67856WESTCivil9.32/16/2026
KYE67856WESTCivil9.32/17/2026
IKOnk867WESTCivil6.162/7/2026
IKOnk867WESTCivil6.162/8/2026
PKPOM0890WESTCivil3.762/3/2026
PKPOM0890WESTCivil3.762/4/2026
PKPOM0890WESTCivil3.762/5/2026
  • hi AllanBerces ,

     

    You can write a calculated table like:

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

     

    it works like:

  • 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"

     

  • 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.

     

  • 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.

6 Replies

  • 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
      Icon for Super User rankSuper User

      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"

       

  • 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.

     

  • 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.