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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
nexus2004
Frequent Visitor

Fecha se encuentra encima del encabezado de columna

Hola a todos,

He importado y archivo de Excel en PowerBi. El archivo tiene datos de ventas, comisiones de ventas y porcentaje de comisiones, desglosados por año y trimestre. El problema es que la fecha del año y del trimestre se encuentra encima de los encabezados de columna (consulte la tabla a continuación). ¿Cómo podría llevar la fecha de arriba a una columna para que pueda estar en un formato de tabla?

202009 YTD202009 YTD 201909 YTD201909 YTD
RegiónTipoEmpresaVentasComisión de VentasComisión VentasComisión de VentasComisión
EsteSuvFord4,081260.6%5,979550.9%
OesteSuvFord4,652541.2%7,703420.5%
NorteSuvFord7,315250.3%3,058581.9%
SurSuvFord6,369420.7%2,188653.0%
EsteSuvGm5,265110.2%2,418512.1%
OesteSuvGm3,173230.7%6,691230.3%
NorteSuvGm6,972640.9%2,721291.1%
SurSuvGm8,366780.9%2,666813.0%

Gracias

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Esta es una manera de hacerlo en el editor de consultas. Para ver cómo funciona, simplemente cree una consulta en blanco, vaya a Editor avanzado y reemplace el texto allí con el código M a continuación.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZFNT8MwDIb/SlWpt6iKndZJznyd4MAGCFU7VFoFk9g6reOwf4/tMFptPXCoXTt+8uZNmibPcvP3oUVrY/a+vL0s0irEyeqkyPKVafLn7mPT77hcnvYdp5t+u293J/5btF/dcM4Z97ebYUizY5H9f1DU7trhKJMvrxzv+8OaU2VsADkccbAlFZxqE32UXGsvFkq/dXM01SiTFQcoUWhvvHWyhkrXiX7qD8fPS9wbB6KBScgJ7oytg2wZdMtf8UX/fY2TcRRHJS84GghCkmzpSltcO394VI+oIwDKYmIrUGm9kBJmfCvrDHhxiG7UJUMRxp6bc60w8eXKeak6X64Ie1Q4qmeY86xwYMfyUD5MYdKePmNyvPoB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t, Column9 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type text}}),
    TimePeriod = List.Select(List.Distinct(Record.ToList(#"Changed Type"{0})), each _ <>" "),
    Custom1 = #"Changed Type",
    #"Removed Top Rows" = Table.Skip(Custom1,1),
    #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Region", type text}, {"Type", type text}, {"Company", type text}, {"Sales", Int64.Type}, {"Sales Commission", Int64.Type}, {"Commission ", Percentage.Type}, {"Sales_1", Int64.Type}, {"Sales Commission_2", Int64.Type}, {"Commission _3", Percentage.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Region", "Type", "Company"}, "Attribute", "Value"),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Unpivoted Other Columns", {{"Attribute", each Text.BeforeDelimiter(_, "_"), type text}}),
    #"Grouped Rows" = Table.Group(#"Extracted Text Before Delimiter", {"Region", "Type", "Company", "Attribute"}, {{"Max", each Table.FromColumns({[Value], TimePeriod})}}),
    #"Expanded Max" = Table.ExpandTableColumn(#"Grouped Rows", "Max", {"Column1", "Column2"}, {"Column1", "Column2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Max",{{"Column1", "Value"}, {"Column2", "Time Period"}}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time Period", type text}, {"Value", type number}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type2", List.Distinct(#"Changed Type2"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

Esta es una manera de hacerlo en el editor de consultas. Para ver cómo funciona, simplemente cree una consulta en blanco, vaya a Editor avanzado y reemplace el texto allí con el código M a continuación.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZFNT8MwDIb/SlWpt6iKndZJznyd4MAGCFU7VFoFk9g6reOwf4/tMFptPXCoXTt+8uZNmibPcvP3oUVrY/a+vL0s0irEyeqkyPKVafLn7mPT77hcnvYdp5t+u293J/5btF/dcM4Z97ebYUizY5H9f1DU7trhKJMvrxzv+8OaU2VsADkccbAlFZxqE32UXGsvFkq/dXM01SiTFQcoUWhvvHWyhkrXiX7qD8fPS9wbB6KBScgJ7oytg2wZdMtf8UX/fY2TcRRHJS84GghCkmzpSltcO394VI+oIwDKYmIrUGm9kBJmfCvrDHhxiG7UJUMRxp6bc60w8eXKeak6X64Ie1Q4qmeY86xwYMfyUD5MYdKePmNyvPoB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t, Column9 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type text}}),
    TimePeriod = List.Select(List.Distinct(Record.ToList(#"Changed Type"{0})), each _ <>" "),
    Custom1 = #"Changed Type",
    #"Removed Top Rows" = Table.Skip(Custom1,1),
    #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Region", type text}, {"Type", type text}, {"Company", type text}, {"Sales", Int64.Type}, {"Sales Commission", Int64.Type}, {"Commission ", Percentage.Type}, {"Sales_1", Int64.Type}, {"Sales Commission_2", Int64.Type}, {"Commission _3", Percentage.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Region", "Type", "Company"}, "Attribute", "Value"),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Unpivoted Other Columns", {{"Attribute", each Text.BeforeDelimiter(_, "_"), type text}}),
    #"Grouped Rows" = Table.Group(#"Extracted Text Before Delimiter", {"Region", "Type", "Company", "Attribute"}, {{"Max", each Table.FromColumns({[Value], TimePeriod})}}),
    #"Expanded Max" = Table.ExpandTableColumn(#"Grouped Rows", "Max", {"Column1", "Column2"}, {"Column1", "Column2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Max",{{"Column1", "Value"}, {"Column2", "Time Period"}}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time Period", type text}, {"Value", type number}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type2", List.Distinct(#"Changed Type2"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


palmadita

¡Gracias por lo que funcionó! El código M está un poco por encima de mi calibur en este momento. ¿Hay una manera más escasa de obtener la misma salida?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors