Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hola, Espero un poco de ayuda, por favor.
Tengo dos mesas
Una de ellas es para las visitas de auditoría de la tienda a continuación.
La otra tabla es para una visita de cumplimiento a continuación. Será necesario separar esta tabla para que los consejos dados tengan su propia columna y todas las demás categorías se combinen en una columna.
El resultado esperado es el siguiente. ¿Es esto posible?
Hola @lennox25,
Estoy usando algunos datos de su publicación inicial y aquí está mi solución:
1. Creé dos tablas como las tuyas: T_Stores y T_StoreDetail.
2. Realice las mismas transformaciones de datos en la tabla T_StoreDetail y el resultado final es este:
El código M está aquí:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdKxCoMwEAbgV5HMQi5njDp2KoVuFjqIg9TYZkkhpj5/VaSVJKUZAx//f1yuaQhCXpGUHPpJ3WRyVJPU8xMFhYIiYEba9IOundFK35OztFaan8zJYpwCLohvSIhAYU6B75NCiGVOXRAxCuUeVSyACqcuhLCMQHMX5H+TeAwSESiDCDQLEB6qH09jk9p2wyD7RYmQcheFEQirCATu563oYjq13tRpHF9ym8pngal85J8nfFn7Bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Store No" = _t, Category = _t, #"Date Sold" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Store No", Int64.Type}, {"Category", type text}, {"Date Sold", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "OtherCat", each if [Category] <> "Advice Given" then "All other Categories" else [Category]),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Store No", "OtherCat"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[OtherCat]), "OtherCat", "Count")
in
#"Pivoted Column"
3. Después de ir a T_Stores tabla y usar la opción de consulta merge, el resultado final es este:
El código M está aquí:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtVTSUXLPz08BUkZm+gbm+kYGRsZKsTogSTMzoGhwYklmcVpickl+USVIkam+gQmKInOgqGduQVF+WWpual6JQl5qakoqyDxDA30DQ5BSE6hScwuEZYYW+kB5JHMsDTEtMzRHWBYLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Store No" = _t, #"Audit Result" = _t, #"Audit Date" = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Store No", Int64.Type}, {"Audit Result", type text}, {"Audit Date", type date}}),
MergedQueries = Table.NestedJoin(ChangedType, {"Store No"}, T_StoreDetail, {"Store No"}, "T_StoreDetail", JoinKind.LeftOuter),
ExpandedT_StoreDetail = Table.ExpandTableColumn(MergedQueries, "T_StoreDetail", {"Advice Given", "All other Categories"}, {"Advice Given", "All other Categories"})
in
ExpandedT_StoreDetail
Excelente opción -¡Muchas gracias!
@lennox25 ¿Mi publicación resolvió su problema como @samratpbi ?
Si es así, por favor marque también mi publicación como una solución, me ayudará.
Gracias.
Hola
Creo que ni siquiera es necesario combinar tablas en Power Query. Lo que puedes hacer es unir las tablas usando la tienda No. y lleva todas las columnas de tu primera tabla a visual y crea 2 medidas como las siguientes:
Consejos dados =
CALCULAR (
COUNTROWS( T2),
T2. Categoría = "Consejos dados"
)
Otras categorías combinadas =
CALCULAR (
COUNTROWS( T2),
T2. Categoría <> "Asesoramiento dado"
)
Si esto resuelve su problema, márquelo como solución, ¡gracias!
Excelente -Gracias- esto ha resuelto fácilmente mi problema 🙂
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!