Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hola a todos
tener una tabla con números de artículo y textos de descripción. Un número de artículo puede tener varios textos descriptivos.
Para esto tengo esta tabla:
Artículo: | Mensaje de texto: |
XY1 | XY1-Text1 |
XY1 | XY1-Text2 |
XY1 | XY1-Text3 |
XY1 | XY1-Text4 |
XY2 | XY2-Text1 |
XY2 | XY2-Text2 |
XY3 | XY3-Text1 |
XY3 | XY3-Text2 |
XY3 | XY3-Text3 |
XY3 | XY3-Text4 |
XY3 | XY3-Text5 |
XY3 | XY3-Text6 |
XY4 | XY4-Text1 |
XY4 | XY4-Text2 |
XY4 | XY4-Text3 |
XY4 | XY4-Text4 |
Pero me gustaría transformarlo de la siguiente manera:
Artículo: | Texto1 | Texto2 | Texto3 | Texto4 | Texto5 | Texto6 |
XY1 | XY1-Text1 | XY1-Text2 | XY1-Text3 | XY1-Text4 | ||
XY2 | XY2-Text1 | XY2-Text2 | ||||
XY3 | XY3-Text1 | XY3-Text2 | XY3-Text3 | XY3-Text4 | XY3-Text5 | XY3-Text6 |
XY4 | XY4-Text1 | XY4-Text2 | XY4-Text3 | XY4-Text4 |
Desafortunadamente no puedo encontrar una solución ... o no tengo idea de cómo resolverlo. Creo que en primer lugar se debe contar el número máximo de textos por número de artículo, entonces estas columnas deben ser generadas y luego todos los datos deben estar en la columna o línea correcta respectiva ...
Solved! Go to Solution.
No @n8schicht ,
Puede copiar y pegar los siguientes códigos en su Editor Avanzado para obtenerlo:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiog0VNIBkbohqRUlhkqxOuhiRljEjLGImUDFjMBiRijmIYvBzDMGixmjqEMWw6bOGIuYCRYxUyxiZlAxE7CYCYq9yGJGWMSMsYgB7Y0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Artikel = _t, Text = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Artikel", type text}, {"Text", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Artikel"}, {{"Count", each Table.AddIndexColumn(_, "Cum",1,1), type table}}),
#"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Text", "Cum"}, {"Text", "Cum"}),
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Expanded Table", {{"Cum", type text}}, "en-US"),
List.Distinct(Table.TransformColumnTypes(#"Expanded Table", {{"Cum", type text}}, "en-US")[Cum]), "Cum", "Text")
in #"Pivoted Column"
Saludos
No @n8schicht ,
Puede actualizar los códigos como se indica a continuación para lograrlo:
Dejar Fuente = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiog0VNIBkbohqRUlhkqxOuhirljEjLGImUDFjMBiRijmYvBzDMGixmjqEMWw6bOGIuYCRYxUyxiZlAxE7CYCYq9yGJGWMSYgB7Y0FAA==", BinaryEncoding.Base64), Compression.Deflate)), deje _t = ((texto con tipo nullable) meta [Serialized.Text = true]) en la tabla de tipos [Artikel = _t, Texto = _t]), #"Tipo cambiado" = Table.TransformColumnTypes(Source,{{"Artikel", escriba text}, {"Text", escriba text}}), #"Filas agrupadas" = Table.Group(#"Tipo cambiado", {"Artikel"}, {{"Count", cada Tabla.AddIndexColumn(_, "Cum",1,1), tipo tabla}}), #"Tabla expandida" = Table.ExpandTableColumn(#"Filas agrupadas", "Count", {"Text", "Cum"}, {"Text", "Cum"}), #"Prefijo insertado" = Table.AddColumn(#"Tabla expandida", "Prefijo", cada "Feature_" y Texto.From([Cum], "en-US"), texto de tipo), #"Columnas eliminadas" = Table.RemoveColumns(#"Prefijo insertado",{"Cum"}), #"Columna pivotada" = Table.Pivot(Table.TransformColumnTypes(#"Columnas eliminadas", {{"Prefix", texto de tipo}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Prefix",type text}}, "en-US")[Prefix]), "Prefix", "Text") En #"Columna pivotada" |
Saludos
@n8schicht , crear una columna en la bruja de consulta de poder igual que el texto
text1 = texto
dividir la columna por delimitador - https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/
mantener la parte 2
y luego se puede unpivot - https://radacad.com/pivot-and-unpivot-with-power-bi
o utilizar esa columna de matriz
lo siento, pero no puedo entender...
No quiero dividir el texto...
Quiero transformar los valores del número de artículo de muchas filas a una fila.... como mostré
así que se ve en mi Power-Query:
y así es como debe tener cuidado después de la edición en Power-Bi:
No @n8schicht ,
Puede copiar y pegar los siguientes códigos en su Editor Avanzado para obtenerlo:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiog0VNIBkbohqRUlhkqxOuhiRljEjLGImUDFjMBiRijmIYvBzDMGixmjqEMWw6bOGIuYCRYxUyxiZlAxE7CYCYq9yGJGWMSMsYgB7Y0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Artikel = _t, Text = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Artikel", type text}, {"Text", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Artikel"}, {{"Count", each Table.AddIndexColumn(_, "Cum",1,1), type table}}),
#"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Text", "Cum"}, {"Text", "Cum"}),
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Expanded Table", {{"Cum", type text}}, "en-US"),
List.Distinct(Table.TransformColumnTypes(#"Expanded Table", {{"Cum", type text}}, "en-US")[Cum]), "Cum", "Text")
in #"Pivoted Column"
Saludos
¡Perfecto! esto es lo que quiero tener! Thx
Todavía tengo una pregunta en su lugar.
¿Hay alguna manera de nombrar automáticamente las columnas numérales creadas dinámicamente?
Sólo quiero tener un "Feature_" delante del número.
Lo hice manualmente después de la creación, pero eso no es una buena manera, porque puede ser que haya más de las 8 columnas mencionadas en este momento en otro registro de datos ...
#"Umbenannte Spalten" = Table.RenameColumns(#"Pivoted Column",{{"1", "Feature_1"}, {"2", "Feature_2"}, {"3", "Feature_3"}, {"4", "Feature_4"}, {"5", "Feature_5"}, {"6", "Feature_6"}, {"7", "Feature_7"}, {"8", "Feature_8"}})
No @n8schicht ,
Puede actualizar los códigos como se indica a continuación para lograrlo:
Dejar Fuente = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiog0VNIBkbohqRUlhkqxOuhirljEjLGImUDFjMBiRijmYvBzDMGixmjqEMWw6bOGIuYCRYxUyxiZlAxE7CYCYq9yGJGWMSYgB7Y0FAA==", BinaryEncoding.Base64), Compression.Deflate)), deje _t = ((texto con tipo nullable) meta [Serialized.Text = true]) en la tabla de tipos [Artikel = _t, Texto = _t]), #"Tipo cambiado" = Table.TransformColumnTypes(Source,{{"Artikel", escriba text}, {"Text", escriba text}}), #"Filas agrupadas" = Table.Group(#"Tipo cambiado", {"Artikel"}, {{"Count", cada Tabla.AddIndexColumn(_, "Cum",1,1), tipo tabla}}), #"Tabla expandida" = Table.ExpandTableColumn(#"Filas agrupadas", "Count", {"Text", "Cum"}, {"Text", "Cum"}), #"Prefijo insertado" = Table.AddColumn(#"Tabla expandida", "Prefijo", cada "Feature_" y Texto.From([Cum], "en-US"), texto de tipo), #"Columnas eliminadas" = Table.RemoveColumns(#"Prefijo insertado",{"Cum"}), #"Columna pivotada" = Table.Pivot(Table.TransformColumnTypes(#"Columnas eliminadas", {{"Prefix", texto de tipo}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Prefix",type text}}, "en-US")[Prefix]), "Prefix", "Text") En #"Columna pivotada" |
Saludos