提取具有多个日期的行的最小最大日期
Extract min max date of a row with multiple dates
如何拆分位于多盘日期行中的最小和最大日期
这是在 Power Query 中
8/31/2018, 8/29/2018, 4/9/2018, 8/29/2018, 8/29/2018
不同列的结果
min max
29/8/2019 4/9/2019
谁能帮我解决一下?
代码:
= Table.TransformColumns(#"Added Custom4", {"FechaFinalTarea", 每个 Text.Combine(List.Transform(_, Text.From), ", ", 输入文字})
enter image description here
完整代码:
让
来源 = Etapa_1_Caricam,
#"Grouped Rows" = Table.Group(来源, {"Num Form"}, {{"mynewtable", 每个_, 输入table [Num Form=text, DupForm=text, Creado En=date, FechaCreac=date, SLA=number, Initiator Name=text, Business Unit=text, BU Description=text, Tipo Form=text, Description del proyecto=text, Texto tarea=text, Field12=number, Task Assigned =text, Status=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Task_Etapa1", 每个 Table.Column([mynewtable],"Texto tarea")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Task_Etapa1", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}),
#"Added Custom1" = Table.AddColumn(#"Extracted Values", "Iniciador", 每个 Table.Column([mynewtable],"Initiator Name")),
#"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"Iniciador", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Extracted Values1", {{"Iniciador", 每个 Text.BeforeDelimiter(, ", "), 输入文字}} ),
#"Added Custom2" = Table.AddColumn(#"Extracted Text Before Delimiter", "Custom", 每个 Table.Column([mynewtable],"Descripción del proyecto")),
#"Extracted Values2" = Table.TransformColumns(#"Added Custom2", {"Custom", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}),
#"Inserted Text Before Delimiter" = Table.AddColumn(#"Extracted Values2", "Text Before Delimiter", 每个 Text.BeforeDelimiter([自定义], ","), 输入文字),
#"Removed Columns" = Table.RemoveColumns(#"Inserted Text Before Delimiter",{"Custom"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Text Before Delimiter", "Descripcion del Proyecto"}}),
#"Added Custom3" = Table.AddColumn(#"Renamed Columns", "FechaInicio", 每个 Table.Column([mynewtable],"Creado En")),
#"Extracted Values3" = Table.TransformColumns(#"Added Custom3", {"FechaInicio", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}),
#"Inserted Text Before Delimiter1" = Table.AddColumn(#"Extracted Values3", "Text Before Delimiter", 每个 Text.BeforeDelimiter([FechaInicio], ", "), 输入文字),
#"Inserted Text After Delimiter" = Table.AddColumn(#"Inserted Text Before Delimiter1", "Text After Delimiter", 每个 Text.AfterDelimiter([FechaInicio], ", "), 输入文字),
#"Removed Columns1" = Table.RemoveColumns(#"Inserted Text After Delimiter",{"Text After Delimiter", "Text Before Delimiter"}),
#"Extracted Text Before Delimiter1" = Table.TransformColumns(#"Removed Columns1", {{"FechaInicio", 每个 Text.BeforeDelimiter(, ", "), 输入文本}} ),
#"Added Custom4" = Table.AddColumn(#"Extracted Text Before Delimiter1", "FechaFinalTarea", 每个 Table.Column([mynewtable],"FechaCreac")),
#"Extracted Values4" = Table.TransformColumns(#"Added Custom4", {"FechaFinalTarea", 每个 Text.Combine(List.Transform(_, Text.From), " , "), 输入文字})
在
#"Extracted Values4"
您输入的数据中没有日期 29/8/2019
(或与 2019 年相关的任何日期)。您还将 "results" 之一显示为 day/month/year
。这可能只是几个错别字,但会使您的 "results" 和问题都不清楚且更难理解。
如果我理解正确,下面的方法之一应该有效。
如果您的初始 table 如下所示(其中所有日期均采用 month/day/year
格式并且是单个逗号分隔字符串的一部分):
然后我得到这个输出(注意列 min
和 max
):
使用此代码:
let
initialTable = Table.FromRows({{"8/31/2018, 8/29/2018, 4/9/2018, 8/29/2018, 8/29/2018"}}),
split = Table.AddColumn(initialTable, "datesToCheck", each List.Transform(Text.Split([Column1], ","), each Date.FromText(_, "en-US")), type list),
minAndMax = Table.AddColumn(split, "toExpand", each [min = List.Min([datesToCheck]), max = List.Max([datesToCheck])], type record),
expanded = Table.ExpandRecordColumn(minAndMax, "toExpand", {"min", "max"})
in
expanded
但是,如果您的初始 table 类似于下面的内容(日期在它们自己的列中开头):
然后我得到这个输出(注意列 min
和 max
):
使用下面的代码:
let
initialTable = Table.FromRows({List.Transform({"8/31/2018", "8/29/2018", "4/9/2018", "8/29/2018", "8/29/2018"}, each Date.FromText(_, "en-US"))}),
split = Table.AddColumn(initialTable, "datesToCheck", each Record.FieldValues(_), type list),
minAndMax = Table.AddColumn(split, "toExpand", each [min = List.Min([datesToCheck]), max = List.Max([datesToCheck])], type record),
expanded = Table.ExpandRecordColumn(minAndMax, "toExpand", {"min", "max"})
in
expanded
根据您的代码,您的 table 似乎包含一个 table 列(称为 mynewtable
),其中有一个名为 FechaCreac
的列,它本身包含日期。我无法对此进行测试,但我建议您在代码中替换这些行:
#"Added Custom4" = Table.AddColumn(#"Extracted Text Before Delimiter1", "FechaFinalTarea", each Table.Column([mynewtable],"FechaCreac")),
#"Extracted Values4" = Table.TransformColumns(#"Added Custom4", {"FechaFinalTarea", each Text.Combine(List.Transform(_, Text.From), ", "), type text})
in
#"Extracted Values4"
与:
#"Added Custom4" = Table.AddColumn(#"Extracted Text Before Delimiter1", "FechaFinalTarea", each let dates = Table.Column([mynewtable],"FechaCreac") in [min = List.Min(dates), max = List.Max(dates)]),
expanded = Table.ExpandRecordColumn(#"Added Custom4", "FechaFinalTarea", {"min", "max"})
in
expanded
然后应该会显示 min
和 max
列。
如何拆分位于多盘日期行中的最小和最大日期
这是在 Power Query 中
8/31/2018, 8/29/2018, 4/9/2018, 8/29/2018, 8/29/2018
不同列的结果
min max
29/8/2019 4/9/2019
谁能帮我解决一下?
代码: = Table.TransformColumns(#"Added Custom4", {"FechaFinalTarea", 每个 Text.Combine(List.Transform(_, Text.From), ", ", 输入文字})
enter image description here
完整代码: 让 来源 = Etapa_1_Caricam, #"Grouped Rows" = Table.Group(来源, {"Num Form"}, {{"mynewtable", 每个_, 输入table [Num Form=text, DupForm=text, Creado En=date, FechaCreac=date, SLA=number, Initiator Name=text, Business Unit=text, BU Description=text, Tipo Form=text, Description del proyecto=text, Texto tarea=text, Field12=number, Task Assigned =text, Status=number]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Task_Etapa1", 每个 Table.Column([mynewtable],"Texto tarea")), #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Task_Etapa1", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}), #"Added Custom1" = Table.AddColumn(#"Extracted Values", "Iniciador", 每个 Table.Column([mynewtable],"Initiator Name")), #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"Iniciador", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}), #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Extracted Values1", {{"Iniciador", 每个 Text.BeforeDelimiter(, ", "), 输入文字}} ), #"Added Custom2" = Table.AddColumn(#"Extracted Text Before Delimiter", "Custom", 每个 Table.Column([mynewtable],"Descripción del proyecto")), #"Extracted Values2" = Table.TransformColumns(#"Added Custom2", {"Custom", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}), #"Inserted Text Before Delimiter" = Table.AddColumn(#"Extracted Values2", "Text Before Delimiter", 每个 Text.BeforeDelimiter([自定义], ","), 输入文字), #"Removed Columns" = Table.RemoveColumns(#"Inserted Text Before Delimiter",{"Custom"}), #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Text Before Delimiter", "Descripcion del Proyecto"}}), #"Added Custom3" = Table.AddColumn(#"Renamed Columns", "FechaInicio", 每个 Table.Column([mynewtable],"Creado En")), #"Extracted Values3" = Table.TransformColumns(#"Added Custom3", {"FechaInicio", 每个 Text.Combine(List.Transform(, Text.From), ", "), 输入文字}), #"Inserted Text Before Delimiter1" = Table.AddColumn(#"Extracted Values3", "Text Before Delimiter", 每个 Text.BeforeDelimiter([FechaInicio], ", "), 输入文字), #"Inserted Text After Delimiter" = Table.AddColumn(#"Inserted Text Before Delimiter1", "Text After Delimiter", 每个 Text.AfterDelimiter([FechaInicio], ", "), 输入文字), #"Removed Columns1" = Table.RemoveColumns(#"Inserted Text After Delimiter",{"Text After Delimiter", "Text Before Delimiter"}), #"Extracted Text Before Delimiter1" = Table.TransformColumns(#"Removed Columns1", {{"FechaInicio", 每个 Text.BeforeDelimiter(, ", "), 输入文本}} ), #"Added Custom4" = Table.AddColumn(#"Extracted Text Before Delimiter1", "FechaFinalTarea", 每个 Table.Column([mynewtable],"FechaCreac")), #"Extracted Values4" = Table.TransformColumns(#"Added Custom4", {"FechaFinalTarea", 每个 Text.Combine(List.Transform(_, Text.From), " , "), 输入文字}) 在 #"Extracted Values4"
您输入的数据中没有日期 29/8/2019
(或与 2019 年相关的任何日期)。您还将 "results" 之一显示为 day/month/year
。这可能只是几个错别字,但会使您的 "results" 和问题都不清楚且更难理解。
如果我理解正确,下面的方法之一应该有效。
如果您的初始 table 如下所示(其中所有日期均采用 month/day/year
格式并且是单个逗号分隔字符串的一部分):
然后我得到这个输出(注意列 min
和 max
):
使用此代码:
let
initialTable = Table.FromRows({{"8/31/2018, 8/29/2018, 4/9/2018, 8/29/2018, 8/29/2018"}}),
split = Table.AddColumn(initialTable, "datesToCheck", each List.Transform(Text.Split([Column1], ","), each Date.FromText(_, "en-US")), type list),
minAndMax = Table.AddColumn(split, "toExpand", each [min = List.Min([datesToCheck]), max = List.Max([datesToCheck])], type record),
expanded = Table.ExpandRecordColumn(minAndMax, "toExpand", {"min", "max"})
in
expanded
但是,如果您的初始 table 类似于下面的内容(日期在它们自己的列中开头):
然后我得到这个输出(注意列 min
和 max
):
使用下面的代码:
let
initialTable = Table.FromRows({List.Transform({"8/31/2018", "8/29/2018", "4/9/2018", "8/29/2018", "8/29/2018"}, each Date.FromText(_, "en-US"))}),
split = Table.AddColumn(initialTable, "datesToCheck", each Record.FieldValues(_), type list),
minAndMax = Table.AddColumn(split, "toExpand", each [min = List.Min([datesToCheck]), max = List.Max([datesToCheck])], type record),
expanded = Table.ExpandRecordColumn(minAndMax, "toExpand", {"min", "max"})
in
expanded
根据您的代码,您的 table 似乎包含一个 table 列(称为 mynewtable
),其中有一个名为 FechaCreac
的列,它本身包含日期。我无法对此进行测试,但我建议您在代码中替换这些行:
#"Added Custom4" = Table.AddColumn(#"Extracted Text Before Delimiter1", "FechaFinalTarea", each Table.Column([mynewtable],"FechaCreac")),
#"Extracted Values4" = Table.TransformColumns(#"Added Custom4", {"FechaFinalTarea", each Text.Combine(List.Transform(_, Text.From), ", "), type text})
in
#"Extracted Values4"
与:
#"Added Custom4" = Table.AddColumn(#"Extracted Text Before Delimiter1", "FechaFinalTarea", each let dates = Table.Column([mynewtable],"FechaCreac") in [min = List.Min(dates), max = List.Max(dates)]),
expanded = Table.ExpandRecordColumn(#"Added Custom4", "FechaFinalTarea", {"min", "max"})
in
expanded
然后应该会显示 min
和 max
列。