如何用列 (M) 中的最新日期替换值
How to replace value by the latest date in the column (M)
我试图将特定值 (Contagem) 替换为列数据中找到的最早日期(减去 01 天),但我不知道如何替换。
这个想法是设置这个最早的日期 - 1 天作为库存盘点的初始日期,然后会有其他日子跟随移动。
let
Fonte = Excel.Workbook(Web.Contents("https://docs.google.com/spreadsheets/d/e/hdsdshjdsh/pub?output=xlsx"), null, true),
Previsão_Sheet = Fonte{[Item="Previsão",Kind="Sheet"]}[Data],
#"Cabeçalhos Promovidos" = Table.PromoteHeaders(Previsão_Sheet, [PromoteAllScalars=true]),
#"Tipo Alterado" = Table.TransformColumnTypes(#"Cabeçalhos Promovidos",{{"Previsão de Produção", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type text}, {"Column5", type text}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}, {"Column11", type any}, {"Column12", type any}, {"Column13", type any}, {"Column14", type any}, {"Column15", type any}, {"Column16", type any}, {"Column17", type any}, {"Column18", type any}, {"Column19", type any}, {"Column20", type any}}),
#"Linhas Principais Removidas" = Table.Skip(#"Tipo Alterado",3),
#"Cabeçalhos Promovidos1" = Table.PromoteHeaders(#"Linhas Principais Removidas", [PromoteAllScalars=true]),
#"Colunas Removidas" = Table.RemoveColumns(#"Cabeçalhos Promovidos1",{"Local"}),
#"Outras Colunas Não Dinâmicas" = Table.UnpivotOtherColumns(#"Colunas Removidas", {"Und", "Descrição", "Cód.", "Categoria"}, "Atributo", "Valor"),
#"Linhas Filtradas" = Table.SelectRows(#"Outras Colunas Não Dinâmicas", each Text.Contains([Atributo], "/") or [Atributo] = "Contagem"),
#"Colunas Renomeadas" = Table.RenameColumns(#"Linhas Filtradas",{{"Atributo", "Data"}})
#"Valor Substituído" = Table.ReplaceValue(#"Colunas Renomeadas","Contagem","31/01/2021",Replacer.ReplaceText,{"Data"})
//#"Valor Substituído" = Table.ReplaceValue(#"Colunas Renomeadas","Contagem", List.Max(Table.RemoveRowsWithErrors(#"Tipo Alterado", {"Atributo"})[Data]),Replacer.ReplaceText,{"Data"})
in
#"Valor Substituído"
最后两行是应该实施解决方案的地方,但是...
如有任何帮助,我将不胜感激。
干杯,
安东尼奥
看看这样的东西是否适合你
- 将数据列转换为文本
- 删除所有其他列
- 将数据列更改为日期
- 删除所有有错误的行
- 使用 List.Min() 获取最小日期,减去一个,使用 Text.From()
转换为文本
- 编辑 - 用新值替换原始数据列的文本
样本
#"Changed Type" = Table.TransformColumnTypes(#"Colunas Renomeadas",{{"Data", type text}}),
newdate= Date.AddDays(List.Min(Table.RemoveRowsWithErrors(Table.TransformColumnTypes(Table.SelectColumns(#"Changed Type",{"Data"}),{{"Data", type datetime}}), {"Data"})[Data]),-1),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","Contagem",Text.From(newdate),Replacer.ReplaceText,{"Data"})
in #"Replaced Value"
我试图将特定值 (Contagem) 替换为列数据中找到的最早日期(减去 01 天),但我不知道如何替换。 这个想法是设置这个最早的日期 - 1 天作为库存盘点的初始日期,然后会有其他日子跟随移动。
let
Fonte = Excel.Workbook(Web.Contents("https://docs.google.com/spreadsheets/d/e/hdsdshjdsh/pub?output=xlsx"), null, true),
Previsão_Sheet = Fonte{[Item="Previsão",Kind="Sheet"]}[Data],
#"Cabeçalhos Promovidos" = Table.PromoteHeaders(Previsão_Sheet, [PromoteAllScalars=true]),
#"Tipo Alterado" = Table.TransformColumnTypes(#"Cabeçalhos Promovidos",{{"Previsão de Produção", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type text}, {"Column5", type text}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}, {"Column11", type any}, {"Column12", type any}, {"Column13", type any}, {"Column14", type any}, {"Column15", type any}, {"Column16", type any}, {"Column17", type any}, {"Column18", type any}, {"Column19", type any}, {"Column20", type any}}),
#"Linhas Principais Removidas" = Table.Skip(#"Tipo Alterado",3),
#"Cabeçalhos Promovidos1" = Table.PromoteHeaders(#"Linhas Principais Removidas", [PromoteAllScalars=true]),
#"Colunas Removidas" = Table.RemoveColumns(#"Cabeçalhos Promovidos1",{"Local"}),
#"Outras Colunas Não Dinâmicas" = Table.UnpivotOtherColumns(#"Colunas Removidas", {"Und", "Descrição", "Cód.", "Categoria"}, "Atributo", "Valor"),
#"Linhas Filtradas" = Table.SelectRows(#"Outras Colunas Não Dinâmicas", each Text.Contains([Atributo], "/") or [Atributo] = "Contagem"),
#"Colunas Renomeadas" = Table.RenameColumns(#"Linhas Filtradas",{{"Atributo", "Data"}})
#"Valor Substituído" = Table.ReplaceValue(#"Colunas Renomeadas","Contagem","31/01/2021",Replacer.ReplaceText,{"Data"})
//#"Valor Substituído" = Table.ReplaceValue(#"Colunas Renomeadas","Contagem", List.Max(Table.RemoveRowsWithErrors(#"Tipo Alterado", {"Atributo"})[Data]),Replacer.ReplaceText,{"Data"})
in
#"Valor Substituído"
最后两行是应该实施解决方案的地方,但是...
如有任何帮助,我将不胜感激。
干杯, 安东尼奥
看看这样的东西是否适合你
- 将数据列转换为文本
- 删除所有其他列
- 将数据列更改为日期
- 删除所有有错误的行
- 使用 List.Min() 获取最小日期,减去一个,使用 Text.From() 转换为文本
- 编辑 - 用新值替换原始数据列的文本
样本
#"Changed Type" = Table.TransformColumnTypes(#"Colunas Renomeadas",{{"Data", type text}}),
newdate= Date.AddDays(List.Min(Table.RemoveRowsWithErrors(Table.TransformColumnTypes(Table.SelectColumns(#"Changed Type",{"Data"}),{{"Data", type datetime}}), {"Data"})[Data]),-1),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","Contagem",Text.From(newdate),Replacer.ReplaceText,{"Data"})
in #"Replaced Value"