Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hola!
Tengo la siguiente tabla:
y quiero obtener esta tabla:
En palabras: en Power Query quiero Intercalar filas con las fechas/horas faltantes que difieran entre sí con de valor un valor constante (3 horas en el ejemplo, en el caso real es cada 3 minutos), para cualquier fecha inicial y fecha final, y para cualquier número de columnas.
Los valores de las nuevas filas deben ser NULL.
Describo en seudocódigo de query steps un tipo de solución que imagino:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc89CoAwDIbhq5TOQtP82bq5CoJ76RXcvL9SEIo1EHinh4+U4oHCdp0BAdEBLQDPuXX3kxfSlM3W6WO1t5EF1exg392j2cSEZs3dZkV4jmYHm3ubWRnNNss/tv2bKCmbrfUG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fecha = _t, #"Columna 1" = _t, #"Columna 2" = _t, #"…" = _t, #"Columna n" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Fecha", type datetime}, {"Columna 1", Int64.Type}, {"Columna 2", Int64.Type}, {"…", Int64.Type}, {"Columna n", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Fecha", Order.Ascending}})
tabla_temp = crear tabla con filas "desde min(columa1) hasta max(columna1) cada 3 horas" y con la misma cantidad de columnas
#"Merge" = merge con tabla_temp
in
#"Merge"
¿tal vez la solución sea otra? Necesito ayuda para obtener la segunda tabla a partir de la primera.
Gracias!
Solved! Go to Solution.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc89CoAwDIbhq5TOQtP82bq5CoJ76RXcvL9SEIo1EHinh4+U4oHCdp0BAdEBLQDPuXX3kxfSlM3W6WO1t5EF1exg392j2cSEZs3dZkV4jmYHm3ubWRnNNss/tv2bKCmbrfUG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fecha = _t, #"Columna 1" = _t, #"Columna 2" = _t, #"…" = _t, #"Columna n" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Columna 1", Int64.Type}, {"Columna 2", Int64.Type}, {"…", Int64.Type}, {"Columna n", Int64.Type}}),
#"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Fecha", type datetime}}, "es-MX"),
NewTable = List.Generate(()=>List.First(#"Changed Type with Locale"[Fecha]),each _ <= List.Last(#"Changed Type with Locale"[Fecha]),each _ + #duration(0,3,0,0)),
#"Converted to Table" = Table.FromList(NewTable, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Merged Queries" = Table.NestedJoin(#"Changed Type with Locale", {"Fecha"}, #"Converted to Table", {"Column1"}, "Merged", JoinKind.RightOuter),
#"Expanded Merged" = Table.ExpandTableColumn(#"Merged Queries", "Merged", {"Column1"}, {"Column1"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Merged",{{"Column1", type datetime}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type1",null,each [Column1],Replacer.ReplaceValue,{"Fecha"}),
#"Removed Columns" = Table.RemoveColumns(#"Replaced Value",{"Column1"}),
#"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Fecha", Order.Ascending}})
in
#"Sorted Rows"
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc89CoAwDIbhq5TOQtP82bq5CoJ76RXcvL9SEIo1EHinh4+U4oHCdp0BAdEBLQDPuXX3kxfSlM3W6WO1t5EF1exg392j2cSEZs3dZkV4jmYHm3ubWRnNNss/tv2bKCmbrfUG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fecha = _t, #"Columna 1" = _t, #"Columna 2" = _t, #"…" = _t, #"Columna n" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Columna 1", Int64.Type}, {"Columna 2", Int64.Type}, {"…", Int64.Type}, {"Columna n", Int64.Type}}),
#"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Fecha", type datetime}}, "es-MX"),
NewTable = List.Generate(()=>List.First(#"Changed Type with Locale"[Fecha]),each _ <= List.Last(#"Changed Type with Locale"[Fecha]),each _ + #duration(0,3,0,0)),
#"Converted to Table" = Table.FromList(NewTable, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Merged Queries" = Table.NestedJoin(#"Changed Type with Locale", {"Fecha"}, #"Converted to Table", {"Column1"}, "Merged", JoinKind.RightOuter),
#"Expanded Merged" = Table.ExpandTableColumn(#"Merged Queries", "Merged", {"Column1"}, {"Column1"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Merged",{{"Column1", type datetime}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type1",null,each [Column1],Replacer.ReplaceValue,{"Fecha"}),
#"Removed Columns" = Table.RemoveColumns(#"Replaced Value",{"Column1"}),
#"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Fecha", Order.Ascending}})
in
#"Sorted Rows"
Thank you!! I'll learn from your code.
Me acabo de dar cuenta que estoy comentando con el usuario pescadicto a una pregunta del usuario pescadicto_
Siempre usé pescadicto, en mi último login tuve que usar mi cuenta organizacional y se creó un usuarion nuevo (al que llamé pescadicto_ y con el que hice la pregunta de arriba), en el login de hoy entró automáticamente el viejo usuario, pescadicto.
En fin... no entiendo que pasa.
Gracias desde ambos usuarios!
Ya estabas en el camino correcto. Genere una lista de todas las marcas de tiempo posibles y luego realice una unión externa.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |