Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
¡Hola!
Creé una tabla que combina varios archivos de Excel en una carpeta de Sharepoint, creando una sola tabla en mi PBI como esta:
| Nombre | Fecha de archivo | Nivel | Valor |
| file_03-02.2024 | 03/02/2024 | DD | 44 |
| file_03-02.2024 | 03/02/2024 | BB | 33 |
| file_09-01.2025 | 09/01/2025 | AA | 10 |
| file_09-01.2025 | 09/01/2025 | YY | 12 |
| file_02-02.2025 | 02/02/2025 | SS | 26 |
| file_02-02.2025 | 02/02/2025 | UU | 65 |
| file_26-03.2025 | 26/03/2025 | BB | 30 |
| file_26-03.2025 | 26/03/2025 | 98 | |
| file_08-04.2025 | 08/04/2025 | II | 43 |
| file_01-05.2025 | 01/05/2025 | OO | 50 |
| file_22-06.2025 | 22/06/2025 | DD | 69 |
| file_07-07.2025 | 07/07/2025 | XX | 70 |
| file_13-08.2025 | 13/08/2025 | ZZ | 88 |
| file_30-09.2025 | 30/09/2025 | AA | 34 |
| file_30-09.2025 | 30/09/2025 | VV | 100 |
| file_05-10.2025 | 05/10/2025 | AA | 77 |
| file_05-10.2025 | 05/10/2025 | EE | 43 |
| file_11-11.2025 | 11/11/2025 | ZZ | 73 |
| file_23-12.2025 | 23/12/2025 | BB | 12 |
| file_23-12.2025 | 23/12/2025 | MESES | 51 |
En Power Query, quiero crear una nueva columna llamada "Year_Quarter" que indica todos los datos del archivo más reciente para cada trimestre del año, en función de: Q1 (1 de enero - 31 de marzo), Q2 (1 de abril - 30 de junio), Q3 (1 de julio - 30 de septiembre) y Q4 (1 de octubre - 31 de diciembre). Quiero hacer esto porque quiero que mi tabla filtre y muestre solo los datos del archivo más reciente para cada trimestre. El resultado final sería este:
| Nombre | Fecha de archivo | Nivel | Valor | Year_Quarter |
| file_03-02.2024 | 03/02/2024 | DD | 44 | 2024-Q1 |
| file_03-02.2024 | 03/02/2024 | BB | 33 | 2024-Q1 |
| file_26-03.2025 | 26/03/2025 | BB | 30 | 2025-T1 |
| file_26-03.2025 | 26/03/2025 | 98 | 2025-T1 | |
| file_22-06.2025 | 22/06/2025 | DD | 69 | 2025-T2 |
| file_30-09.2025 | 30/09/2025 | AA | 34 | 2025-Q3 |
| file_30-09.2025 | 30/09/2025 | VV | 100 | 2025-Q3 |
| file_23-12.2025 | 23/12/2025 | BB | 12 | 2025-4º trimestre |
| file_23-12.2025 | 23/12/2025 | MESES | 51 | 2025-4º trimestre |
¿Cómo puedo hacer esto?
Solved! Go to Solution.
Hola
Este código M funciona
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Inserted year and quarter" = Table.AddColumn(Source, "Year-Quarter", each Text.From(Date.Year([FileDate]))&" Q-"&Text.From(Date.QuarterOfYear([FileDate]))),
#"Grouped Rows" = Table.Group(#"Inserted year and quarter", {"Year-Quarter"}, {{"Count", each Table.SelectRows(Table.AddRankColumn(_,"Rank",{"FileDate", Order.Descending},[RankKind = RankKind.Competition]),each [Rank]<2)}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"FileName", "FileDate", "Level ", "Value "}, {"FileName", "FileDate", "Level ", "Value "})
in
#"Expanded Count"
Espero que esto ayude.
Hola
Este código M funciona
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Inserted year and quarter" = Table.AddColumn(Source, "Year-Quarter", each Text.From(Date.Year([FileDate]))&" Q-"&Text.From(Date.QuarterOfYear([FileDate]))),
#"Grouped Rows" = Table.Group(#"Inserted year and quarter", {"Year-Quarter"}, {{"Count", each Table.SelectRows(Table.AddRankColumn(_,"Rank",{"FileDate", Order.Descending},[RankKind = RankKind.Competition]),each [Rank]<2)}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"FileName", "FileDate", "Level ", "Value "}, {"FileName", "FileDate", "Level ", "Value "})
in
#"Expanded Count"
Espero que esto ayude.
¿Cuál es tu definición de una moneda de veinticinco centavos?
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZLJagMxDIZfpcw5rhavc0xIAiGHkENCFoaeWij0/c+Vp7arKRQ8DD/IfBK/ludz+Pj8en9Da5BfGdm9yDesBrSADOVB4u1WxLlhWvVmbDYi1qqM0SDlDJ/pEZCgBOu1CGEPer9nlBXKxceMcvGQg/1ehEMPermIBP+LcjBoK8oBpLkS/LSFPej5LDImZSAZdM1AAnQVPRzyePWwyKBvKAH6ip5OIl4bkLZCMyBthYrOSwujqhoNxlY1gvwluN1EoqpKst9UUZLdpoo+HiJJtWXR4FhRiyAL04u1rge9Xucb0EfgDWEz64FwUTbGHnS3+zNYIkPttIiAaNFXVChbQ+1e2ALx4gj0Ff6PHo95XTRM0zc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [FileName = _t, FileDate = _t, #"Level " = _t, #"Value " = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"FileName", type text}, {"FileDate", type date}, {"Level ", type text}, {"Value ", Int64.Type}},"en-GB"),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Quarter", each Text.From(Date.Year([FileDate])) & "-Q" & Text.From(Date.QuarterOfYear([FileDate])),type text),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Quarter"}, {{"Max Date", each List.Max([FileDate]), type nullable date}, {"Rows", each _, type table [FileName=nullable text, FileDate=nullable date, #"Level "=nullable text, #"Value "=nullable number, Quarter=text]}}),
#"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"FileName", "FileDate", "Level ", "Value "}, {"FileName", "FileDate", "Level ", "Value "}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Rows", each [FileDate] = [Max Date]),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Max Date"})
in
#"Removed Columns"
Cómo usar este código: Cree una nueva consulta en blanco. Haga clic en "Editor avanzado". Reemplace el código de la ventana por el código que se proporciona aquí. Haga clic en "Listo". Una vez que haya examinado el código, reemplace todo el paso Origen por su propio origen.
@nok Puede crear una columna personalizada con la siguiente fórmula:
= Text.From(Date.Year([FileDate])) & "-Q" & Text.From(Date.QuarterOfYear([FileDate]))
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.