Forum Discussion
AllanBerces
Post Prodigy
7 months agoMin 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...
- 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:
- 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" - 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.
- 7 months ago
In Power Query:
- Transform data → Power Query
- Select your table
- Keep only Job and Date
- 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.
FreemanZ
Super User
7 months agohi AllanBerces ,
You can write a calculated table like:
Table =
ADDCOLUMNS(
VALUES(Table1[Job]),
"Early Start",
CALCULATE(MIN(Table1[Date]))
)
it works like:
FreemanZ
Super User
7 months agoIf 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"