Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hola
Tengo dos fuentes:
1 - con A, B, C como etiquetas de columnas
2 - con A, B, D como etiquetas de columnas
Quiero como salida: A, B, (C o D)
El C o D está condicionado a la Columna B
Ambas fuentes son empujadas desde mi CRM en una base periódica en un formato XLSX. Y uso como fuente una carpeta.
¿Cómo debo proceder? ¿Crear 2 fuentes?
Gracias
Solved! Go to Solution.
Hola @fred_gc ,
¿Qué te parece esto:
let
Source = Folder.Files("C:\xxx\xxx\xxx\xxx"),
#"Added Custom" = Table.AddColumn(Source, "Workbook", each Excel.Workbook(File.Contents([Folder Path]&"\"&[Name]), null, true)),
#"Expanded Workbook" = Table.ExpandTableColumn(#"Added Custom", "Workbook", {"Name", "Data", "Item", "Kind", "Hidden"}, {"Name.1", "Data", "Item", "Kind", "Hidden"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Workbook", each ([Kind] = "Table")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Name", "Folder Path", "Data"}),
#"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"A", "B", "C", "D"}, {"A", "B", "C", "D"}),
#"Added Custom1" = Table.AddColumn(#"Expanded Data", "C/D", each if [B] = "B1" then [C] else [D]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"C", "D"}),
#"Filtered Rows1" = Table.SelectRows(#"Removed Columns", each ([#"C/D"] <> null))
in
#"Filtered Rows1"
BTW, archivo .pbix adjunto.
Saludos
Icey
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Hola @fred_gc ,
¿Qué te parece esto:
let
Source = Folder.Files("C:\xxx\xxx\xxx\xxx"),
#"Added Custom" = Table.AddColumn(Source, "Workbook", each Excel.Workbook(File.Contents([Folder Path]&"\"&[Name]), null, true)),
#"Expanded Workbook" = Table.ExpandTableColumn(#"Added Custom", "Workbook", {"Name", "Data", "Item", "Kind", "Hidden"}, {"Name.1", "Data", "Item", "Kind", "Hidden"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Workbook", each ([Kind] = "Table")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Name", "Folder Path", "Data"}),
#"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"A", "B", "C", "D"}, {"A", "B", "C", "D"}),
#"Added Custom1" = Table.AddColumn(#"Expanded Data", "C/D", each if [B] = "B1" then [C] else [D]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"C", "D"}),
#"Filtered Rows1" = Table.SelectRows(#"Removed Columns", each ([#"C/D"] <> null))
in
#"Filtered Rows1"
BTW, archivo .pbix adjunto.
Saludos
Icey
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
@fred_gc , En primer lugar, anexe estas dos tablas. Va a columnas A,B,C,D
https://radacad.com/append-vs-merge-in-power-bi-and-power-query
A continuación, puede escribir una columna de condición en Power Query o DAX
Ejemplo
M
E- Si [B] - "ABC" entonces [C] más [D]
Dax
E á if([B]- "ABC" ,[C] ,[D])
Gracias por tu respuesta.
No estaba en mi primer problema: Como estoy usando una carpeta donde se almacenan todos mis XLXS (2 tipos de archivo generados cada mes) me pregunto cómo dans este tipo de origen de datos (carpeta i puede importar archivos con diferente estructura.
@fred_gc , Puede importar archivos desde una carpeta, deben tener la misma estructura
Ejemplo
https://powerbi.microsoft.com/en-us/blog/combining-excel-files-hosted-on-a-sharepoint-folder/
https://insightsoftware.com/blog/power-bi-load-data-from-folder/
Para una estructura diferente de la misma carpeta podría tener código en M
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.