Forum Discussion
Anonymous
5 years agoNot applicable
Create a new table depending on range
Hi there, I want to create a new table depending on range, I got the following data; but I want to see it the following way; Thanks in advanced.
mahoneypat
5 years agoMicrosoft Employee
Para ello, puede crear una nueva columna con una lista de las fechas entre la fecha de inicio y la fecha de finalización y, a continuación, expandir esa lista a nuevas filas. Vea el código M de ejemplo a continuación (tenga en cuenta que comencé en una configuración regional de fecha diferente, por lo que es posible que deba agregar un paso con mis datos de ejemplo para cambiar a la configuración regional). Para ver cómo funciona, simplemente cree una consulta en blanco, vaya a Editor avanzado y reemplace el texto allí con el código M a continuación.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJQ0gEyjeFsIBGrE61khJA10jeygLFNgLKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [StartDate = _t, EndDate = _t, Rate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"StartDate", type date}, {"EndDate", type date}, {"Rate", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Dates", each List.Dates([StartDate], Duration.TotalDays([EndDate]-[StartDate])+1, #duration(1,0,0,0))),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Dates", "Rate"}),
#"Expanded Dates" = Table.ExpandListColumn(#"Removed Other Columns", "Dates")
in
#"Expanded Dates"
saludos
palmadita