apmulhearn
Hola,
Tengo dos mesas. Uno tiene la cantidad de veces que un cliente potencial (identificado únicamente por su ID de HubSpot en los ejemplos). Uno tiene los casos en los que realmente hacen una compra / reserva.
Se pueden asignar varias consultas a una reserva, pero solo se puede asignar una reserva a una consulta.
Cualquier consulta antes de una fecha de reserva se atribuirá a esa fecha de reserva. Después de eso, esperan ser atribuidos al siguiente.
Este enlace lo llevará a una AirTable, que contiene una foto y una hoja de cálculo en la columna «Adjunto», que son una representación muy burda de lo que tengo que trabajar.
Tabla 1 (muestra)
Hilera | ID de HubSpot | Consulta | Fecha de consulta |
1 | 1234 | Sitio web | 1/5/2018 |
2 | 5678 | Social | 12/6/2018 |
3 | 9876 | Orgánico | 01/04/2019 |
4 | 1234 | Sitio web | 2/3/2018 |
5 | 1234 | Social | 5/10/2019 |
6 | 5678 | Social | 9/03/2019 |
7 | 9876 | Orgánico | 6/5/2018 |
8 | 9876 | Sitio web | 8/2/2019 |
9 | 9876 | Social | 1/1/2018 |
10 | 4567 | Orgánico | 9/7/2019 |
11 | 6789 | Sitio web | 5/8/2018 |
12 | 9876 | Orgánico | 1/1/2020 |
Tabla 2 (muestra)
Hilera | ID de HubSpot | Fecha de reserva |
A | 1234 | 03/12/2019 |
B | 5678 | 15/9/2019 |
C | 9876 | 8/8/2018 |
D | 9876 | 15/6/2019 |
Maqueta del resultado ideal
Hilera | ID de HubSpot | Consulta | Fecha de consulta | Fecha de reserva atribuida a | Fila atribuida a |
1 | 1234 | Sitio web | 1/5/2018 | 03/12/2019 | A |
2 | 5678 | Social | 12/6/2018 | 15/9/2019 | B |
3 | 9876 | Orgánico | 01/04/2019 | 15/6/2019 | D |
4 | 1234 | Sitio web | 2/3/2018 | 03/12/2019 | A |
5 | 1234 | Social | 5/10/2019 | 03/12/2019 | A |
6 | 5678 | Social | 9/03/2019 | 15/9/2019 | B |
7 | 9876 | Orgánico | 6/5/2018 | 8/8/2018 | C |
8 | 9876 | Sitio web | 8/2/2019 | 15/6/2019 | D |
9 | 9876 | Social | 1/1/2018 | 8/8/2018 | C |
10 | 4567 | Orgánico | 9/7/2019 | ||
11 | 6789 | Sitio web | 5/8/2018 | ||
12 | 9876 | Orgánico | 1/1/2020 |
Gracias.
dax
Hola @apmulhearn,
Puede consultar el código M a continuación para obtener más detalles
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDNCgIxDITfpeeFNOn/U3jwsIfSw7osUhAF9f0xtWJ2oacMYZj5kpwVqkkhGctj3i6v+t5YOUAgjVGVKStqCx8ij/NjrcuNhQckcRjepBg8j9Pzutzrysr2jPR12FGLgV2GE8e/BTU4yfADDgNJDGGE4cBLSRSHYBBEyUjiEIz9N1C325jj0BL2HNh+yqDpUBP7Lb8UGrH2ItKqlA8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Row = _t, #"HubSpot ID" = _t, Inquiry = _t, #"Inquiry Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Row", Int64.Type}, {"HubSpot ID", Int64.Type}, {"Inquiry", type text}, {"Inquiry Date", type date}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"HubSpot ID"}, Table2, {"HubSpot ID"}, "Table2", JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "Table2", {"Row", "Reservation Date"}, {"Row.1", "Reservation Date"}),
Custom1 = Table.ReplaceValue(#"Expanded Table2", each [Row.1], each if [Inquiry Date]<[Reservation Date] then [Row.1] else null, Replacer.ReplaceValue, {"Row.1"}),
Custom2 = Table.ReplaceValue(Custom1, each [Reservation Date], each if [Inquiry Date]<[Reservation Date] then [Reservation Date] else null, Replacer.ReplaceValue, {"Reservation Date"}),
#"Grouped Rows" = Table.Group(Custom2, {"Row"}, {{"min", each List.Min([Reservation Date]), type date}, {"all", each _, type table [Row=number, HubSpot ID=number, Inquiry=text, Inquiry Date=date, Row.1=text, Reservation Date=date]}}),
#"Expanded all" = Table.ExpandTableColumn(#"Grouped Rows", "all", {"HubSpot ID", "Inquiry", "Inquiry Date", "Row.1", "Reservation Date"}, {"HubSpot ID", "Inquiry", "Inquiry Date", "Row.1", "Reservation Date"}),
#"Added Custom" = Table.AddColumn(#"Expanded all", "Custom", each if [min]=[Reservation Date] then [Reservation Date] else 0),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> 0)),
#"Removed Duplicates" = Table.Distinct(#"Filtered Rows"),
#"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates",{"min", "Custom"})
in
#"Removed Columns"
Atentamente,
Zoe Zhi
Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los demás miembros a encontrarla más rápidamente.
dax
Hola @apmulhearn,
Puede consultar el código M a continuación para obtener más detalles
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDNCgIxDITfpeeFNOn/U3jwsIfSw7osUhAF9f0xtWJ2oacMYZj5kpwVqkkhGctj3i6v+t5YOUAgjVGVKStqCx8ij/NjrcuNhQckcRjepBg8j9Pzutzrysr2jPR12FGLgV2GE8e/BTU4yfADDgNJDGGE4cBLSRSHYBBEyUjiEIz9N1C325jj0BL2HNh+yqDpUBP7Lb8UGrH2ItKqlA8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Row = _t, #"HubSpot ID" = _t, Inquiry = _t, #"Inquiry Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Row", Int64.Type}, {"HubSpot ID", Int64.Type}, {"Inquiry", type text}, {"Inquiry Date", type date}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"HubSpot ID"}, Table2, {"HubSpot ID"}, "Table2", JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "Table2", {"Row", "Reservation Date"}, {"Row.1", "Reservation Date"}),
Custom1 = Table.ReplaceValue(#"Expanded Table2", each [Row.1], each if [Inquiry Date]<[Reservation Date] then [Row.1] else null, Replacer.ReplaceValue, {"Row.1"}),
Custom2 = Table.ReplaceValue(Custom1, each [Reservation Date], each if [Inquiry Date]<[Reservation Date] then [Reservation Date] else null, Replacer.ReplaceValue, {"Reservation Date"}),
#"Grouped Rows" = Table.Group(Custom2, {"Row"}, {{"min", each List.Min([Reservation Date]), type date}, {"all", each _, type table [Row=number, HubSpot ID=number, Inquiry=text, Inquiry Date=date, Row.1=text, Reservation Date=date]}}),
#"Expanded all" = Table.ExpandTableColumn(#"Grouped Rows", "all", {"HubSpot ID", "Inquiry", "Inquiry Date", "Row.1", "Reservation Date"}, {"HubSpot ID", "Inquiry", "Inquiry Date", "Row.1", "Reservation Date"}),
#"Added Custom" = Table.AddColumn(#"Expanded all", "Custom", each if [min]=[Reservation Date] then [Reservation Date] else 0),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> 0)),
#"Removed Duplicates" = Table.Distinct(#"Filtered Rows"),
#"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates",{"min", "Custom"})
in
#"Removed Columns"
Atentamente,
Zoe Zhi
Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los demás miembros a encontrarla más rápidamente.
Amitchandak
Refiera, si esto puede ayudar
https://radacad.com/append-vs-merge-in-power-bi-and-power-query
https://docs.microsoft.com/en-us/power-bi/desktop-shape-and-combine-data
Anónimo
@apmulhearn ¿Puede hacer un simulacro en una hoja de cálculo de cómo desea ver los datos en sus informes finales? No está claro qué pretende visualizar en sus informes. Gracias, Chandu
apmulhearn
En respuesta a Anónimo
Hola. Gracias. He agregado tablas de muestra a la publicación usando la función de creación de tablas en este widget de cuadro de texto.
También hay un enlace en la publicación a una AirTable donde se adjunta el documento de Excel. No pude insertar directamente ningún archivo adjunto aquí.
Se agradece enormemente la ayuda. @Anónimo
apmulhearn
En respuesta a Anónimo
Hola. Gracias. He agregado tablas de muestra a la publicación usando la función de creación de tablas en este widget de cuadro de texto.
También hay un enlace en la publicación a una AirTable donde se adjunta el documento de Excel. No pude insertar directamente ningún archivo adjunto aquí.
Se agradece enormemente la ayuda.