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.
Solved! Go to Solution.
Aquí construyo un ejemplo para mostrarle cómo obtener el rango en la consulta de energía de acuerdo con EMP y usar el rango en dos tablas por id de cliente.
Cuadro A:
TablaB:
Agregue una columna de clasificación en TableA:
Ordenar TableA por año, mes y EMP. Aquí ordeno por asce. A continuación, agrupe todas las filas por columna Año y Mes y, a continuación, agregue la columna de índice en el editor avanzado y expanda la tabla para obtener el resultado.
...
...
Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIyMDIEUqZAbGygFKsTreSEKmoEEXVGFTU0BYsimWAGEjVDNwEsao5uAljUEizqgioKsi0WAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer ID" = _t, Year = _t, Month = _t, Emp = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer ID", type text}, {"Year", Int64.Type}, {"Month", Int64.Type}, {"Emp", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Month", Order.Ascending}, {"Emp", Order.Ascending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"Year", "Month"}, {{"Rows", each _, type table [Customer ID=nullable text, Year=nullable number, Month=nullable number, Emp=nullable number]}}),
Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
#"Expanded Rows" = Table.ExpandTableColumn(Indexed, "Rows", {"Customer ID", "Emp", "GroupIndex"}, {"Rows.Customer ID", "Rows.Emp", "Rows.GroupIndex"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Rows.Customer ID", "Customer ID"}, {"Rows.Emp", "Emp"}, {"Rows.GroupIndex", "GroupIndex"}})
in
#"Renamed Columns"
A continuación, agregue una columna personalizada en la tabla B.
(x) =>Table.SelectRows(#"Table A", each _[Customer ID] = x[Customer ID] and _[Year] = x[Year] and _[Month] = x[Month]){0}[GroupIndex]
Reemplace error por null y obtenga result.
Saludos
Rico Zhou
Si este post ayuda,entonces por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Aquí construyo un ejemplo para mostrarle cómo obtener el rango en la consulta de energía de acuerdo con EMP y usar el rango en dos tablas por id de cliente.
Cuadro A:
TablaB:
Agregue una columna de clasificación en TableA:
Ordenar TableA por año, mes y EMP. Aquí ordeno por asce. A continuación, agrupe todas las filas por columna Año y Mes y, a continuación, agregue la columna de índice en el editor avanzado y expanda la tabla para obtener el resultado.
...
...
Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIyMDIEUqZAbGygFKsTreSEKmoEEXVGFTU0BYsimWAGEjVDNwEsao5uAljUEizqgioKsi0WAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer ID" = _t, Year = _t, Month = _t, Emp = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer ID", type text}, {"Year", Int64.Type}, {"Month", Int64.Type}, {"Emp", Int64.Type}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Month", Order.Ascending}, {"Emp", Order.Ascending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"Year", "Month"}, {{"Rows", each _, type table [Customer ID=nullable text, Year=nullable number, Month=nullable number, Emp=nullable number]}}),
Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
#"Expanded Rows" = Table.ExpandTableColumn(Indexed, "Rows", {"Customer ID", "Emp", "GroupIndex"}, {"Rows.Customer ID", "Rows.Emp", "Rows.GroupIndex"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Rows.Customer ID", "Customer ID"}, {"Rows.Emp", "Emp"}, {"Rows.GroupIndex", "GroupIndex"}})
in
#"Renamed Columns"
A continuación, agregue una columna personalizada en la tabla B.
(x) =>Table.SelectRows(#"Table A", each _[Customer ID] = x[Customer ID] and _[Year] = x[Year] and _[Month] = x[Month]){0}[GroupIndex]
Reemplace error por null y obtenga result.
Saludos
Rico Zhou
Si este post ayuda,entonces por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Lo sentimos, teniendo problemas para seguir, ¿puede publicar datos de ejemplo como texto y salida esperada?
No hay realmente suficiente información para continuar, por favor, primero verifique si su problema es un problema común que aparece aquí: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Además, consulte esta publicación sobre cómo obtener una respuesta rápida a su pregunta: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Las partes más importantes son:
1. Datos de muestra como texto, utilice la herramienta de tabla en la barra de edición
2. Salida esperada de los datos de la muestra
3. Explicación en palabras de cómo llegar de 1. a 2.
Covering 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 |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |