Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
IgorGershenson
Helper II
Helper II

fórmula personalizada en el modo de consulta que enumera todos los valores distintos de una variable determinada (consulte el ejemplo)

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 cuentaProgramasProgramas-todo
AbcTelemarketingTelemarketing; Anuncio en línea
AbcAnuncio en líneaTelemarketing; Anuncio en línea
BbdWebWeb; Conferencia
BbdConferenciaWeb; Conferencia
1 ACCEPTED SOLUTION

Echa un vistazo a este código M, ya que dijiste "Consulta"

Genera esta tabla

2020-04-20 14_30_36-Untitled - Power Query Editor.png

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"


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

Quizás:

Programs-all DAX Column =
  CONCATENATEX(
    DISTINCT(
      SELECTCOLUMNS(
        FILTER('Table','Table'[Account ID] = EARLIER('Table'[Account ID])),
        "__Programs",'Table'[Programs]
      )
    ),
    [__Programs],
    ";"
  )


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

¿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



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Voy a ver esto. Gracias

edhans
Super User
Super User

¿No es eso lo que es la columna Programas, una lista de los valores distintos?

Si no es así, proporcione la salida esperada.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Lo 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

2020-04-20 14_30_36-Untitled - Power Query Editor.png

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"


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors