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.
Mi consulta crea las dos columnas a la izquierda, pero ¿cómo agrego la tercera columna que enumera todos los valores de programa distintos para cada cuenta? Por favor, ayúdeme. Gracias
ID de cuenta | Programas | Programas-todo |
Abc | Telemarketing | Telemarketing; Anuncio en línea |
Abc | Anuncio en línea | Telemarketing; Anuncio en línea |
Bbd | Web | Web; Conferencia |
Bbd | Conferencia | Web; Conferencia |
Solved! Go to Solution.
Echa un vistazo a este código M, ya que dijiste "Consulta"
Genera esta tabla
Lo hice en varios pasos para que pudieras ver cómo funcionaba cada uno.
1) En Power Query, seleccione Nuevo origen y, a continuación, Consulta en blanco
2) En la cinta inicio, seleccione el botón "Editor avanzado"
3) Retire todo lo que ve, luego pegue el código M que le he dado en ese cuadro.
4) Pulse Hecho
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVtJRCknNSc1NLMpOLcnMS1eK1YGJ++flZOalKjimgMWcnFyAYuGpSQpIXOf8vLTUotS85FSl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Account ID" = _t, Programs = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Account ID", type text}, {"Programs", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Account ID"}, {{"All Rows", each _, type table [Account ID=text, Programs=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Programs Column", each Table.SelectColumns([All Rows], "Programs")),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each Table.ToList([Programs Column])),
#"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Extracted Values", "All Rows", {"Programs"}, {"Programs"}),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded All Rows",{"Account ID", "Programs", "Custom"})
in
#"Removed Other Columns"
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingQuizás:
Programs-all DAX Column =
CONCATENATEX(
DISTINCT(
SELECTCOLUMNS(
FILTER('Table','Table'[Account ID] = EARLIER('Table'[Account ID])),
"__Programs",'Table'[Programs]
)
),
[__Programs],
";"
)
¿Hay alguna manera de crear el mismo tipo de lógica usando el código M en una consulta?
Hola @IgorGershenson ,
Pruebe este código m:
Dejar
Fuente: Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxOzi/NK1HwdFHSUQooyk8vSswtRmLqJubkKMXqABU6OQOFQ1JzUnMTi7JTSzLz0tH51gr+eTmZeakkil IWhBiBJQ7OYHcEJ6apAChrBWc8/PSUotS85JTkRQgCWJRFgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t á ((texto de tipo) meta [Serialized.Text ? true]) en la tabla de tipos ["(blank)_t" "(en blanco).1" á _t, "(en blanco).2" a _t]),
"Tipo modificado" ? Tabla.TransformColumnTypes(Fuente,"(en blanco)", escriba text, á"(blank).1", escriba text, ?, ?2", escriba text?), escriba text?), escriba text?), escriba text?), escriba text?), escriba text?), escriba text,2", escriba text?),
"Columnas eliminadas" ? Tabla.RemoveColumns("Tipo cambiado", "(en blanco).2"-),
"Encabezados promocionados" ? Table.PromoteHeaders("Columnas eliminadas", [PromoteAllScalars-true]),
"Changed Type1" á Table.TransformColumnTypes(''Encabezados promocionados''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
"Texto recortado" ? Tabla.TransformColumns("Changed Type1", "ID de cuenta", Text.Trim, texto de texto, "Programa", Text.Trim, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto, texto
"Filas agrupadas" - Tabla.Grupo("Texto recortado", "ID de cuenta", "Filas", cada _, tabla de texto [ID de cuenta, texto, Programas, texto], , , , ,
"Añadido personalizado" - Tabla.AddColumn ("Filas agrupadas", "Personalizado", cada Text.Combine(Table.ToList(Table.Distinct(Table.SelectColumns([Rows], "Programs"))), ",")),
"Columnas eliminadas1" ? Tabla.RemoveColumns("Añadido Personalizado", "Filas"-),
"Columna duplicada" á Table.DuplicateColumn(?"Columnas eliminadas1", "Personalizado", "Personalizado - Copiar"),
"Dividir columna por delimitador" á Table.ExpandListColumn(Table.TransformColumns(?"Columna duplicada", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType á (escribir texto que acepta valores NULL) meta [Serialized.Text ? true] en el tipo de tipo .itemType, "Custom"), "Custom"), "Custom"), "Custom"),
"Changed Type2" ? Table.TransformColumnTypes("Split Column by Delimiter","Custom", escriba text?),
"Columnas renombradas" ? Table.RenameColumns(?"Changed Type2", "Custom - Copy", "Programs-all",),
"Changed Type3" ? Table.TransformColumnTypes("Columnas renombradas", "Programas-todo", texto de tipo)
En
"Tipo cambiado3"
Ricardo
Voy a ver esto. Gracias
¿No es eso lo que es la columna Programas, una lista de los valores distintos?
Si no es así, proporcione la salida esperada.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingLo siento. No estaba claro. La columna llamada Programas todos (a la derecha) es mi salida esperada. Esa es la que quiero crear pero no estoy seguro de cómo o qué fórmula funcionará aquí.
Echa un vistazo a este código M, ya que dijiste "Consulta"
Genera esta tabla
Lo hice en varios pasos para que pudieras ver cómo funcionaba cada uno.
1) En Power Query, seleccione Nuevo origen y, a continuación, Consulta en blanco
2) En la cinta inicio, seleccione el botón "Editor avanzado"
3) Retire todo lo que ve, luego pegue el código M que le he dado en ese cuadro.
4) Pulse Hecho
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVtJRCknNSc1NLMpOLcnMS1eK1YGJ++flZOalKjimgMWcnFyAYuGpSQpIXOf8vLTUotS85FSl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Account ID" = _t, Programs = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Account ID", type text}, {"Programs", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Account ID"}, {{"All Rows", each _, type table [Account ID=text, Programs=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Programs Column", each Table.SelectColumns([All Rows], "Programs")),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each Table.ToList([Programs Column])),
#"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Expanded All Rows" = Table.ExpandTableColumn(#"Extracted Values", "All Rows", {"Programs"}, {"Programs"}),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded All Rows",{"Account ID", "Programs", "Custom"})
in
#"Removed Other Columns"
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCovering 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 |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |