Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Así que estoy tratando de incorporar páginas PDF a mi modelo de datos. Con el fin de mantener la ingesta de datos dinámica, necesito configurar una instrucción try/otherwise de otro modo, ya que algunos PDF podrían tener 5 páginas, pero otros solo 3. Tendría la configuración de consultas para cada página, pero las consultas para las páginas 4 y 5 fallarían para un PDF de 3 páginas causando un error en una actualización.
¿Cómo puedo configurar el código m para probar la consulta y, si se produce un error, no hacer nada o simplemente seguir adelante para que no se produzca una error en toda la actualización?
Hola @nobodyukno ,
Puede intentar utilizar la función List.RemoveNulls() y añadir try de otra manera instrucción en ella, aquí está el ejemplo que puede referir como su necesidad:
let
Source =
Table.Combine(
List.RemoveNulls({
Table.FromRecords({[CustomerID = 1, Name = "Bob"]}), //Query 1
Table.FromRecords({[CustomerID = 2, Name = "Jim"]}), //Query 2
try
Table.FindText() //Query 3 which represents error
otherwise
null,
Table.FromRecords({[CustomerID = 3, Name = "AAA"]}), // Query 4
try
Table.FirstValue() //Query 5 which represents error
otherwise
null,
Table.FromRecords({[CustomerID = 4, Name = "BBB"]}) // Query 6
})
)
in
Source
Best Looks,
Yingjie Li
Si este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Sólo estoy usando una importación básica de una página en PDF desde SharePoint. No hay transformación de datos realmente en absoluto.
Consulta original:
let
Source = SharePoint.Files("https://xxxxx.sharepoint.com/personal/xxxxx_com/", [ApiVersion = 15]),
#"Filtered Rows2" = Table.SelectRows(Source, each Text.StartsWith([Name], "DailyStatement")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows2",{{"Date created", Order.Descending}}),
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",1),
#"Filtered Hidden Files1" = Table.SelectRows(#"Kept First Rows", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File (4)", each #"Transform File (4)"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File (4)"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File (4)", Table.ColumnNames(#"Transform File (4)"(#"Sample File (4)")))
in
#"Expanded Table Column1"
Ir a esta ruta con SharePoint crea las 4 consultas auxiliares:
SampleFile
let
Source = SharePoint.Files("https://xxxxxxmy.sharepoint.com/personal/xxxxxxx_com/", [ApiVersion = 15]),
#"Filtered Rows2" = Table.SelectRows(Source, each Text.StartsWith([Name], "DailyStatement")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows2",{{"Date created", Order.Descending}}),
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",1),
Navigation1 = #"Kept First Rows"{0}[Content]
in
Navigation1
Parámetro
#"Sample File (4)" meta [IsParameterQuery=true, BinaryIdentifier=#"Sample File (4)", Type="Binary", IsParameterQueryRequired=true]
Transformar archivo
let
Source = (Parameter4) => let
Source = Pdf.Tables(Parameter4, [Implementation="1.1"]),
Page1 = Source{[Id="Page002"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Page1, [PromoteAllScalars=true])
in
#"Promoted Headers"
in
Source
Transformar archivo de muestra
let
Source = Pdf.Tables(Parameter4, [Implementation="1.1"]),
Page1 = Source{[Id="Page002"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Page1, [PromoteAllScalars=true])
in
#"Promoted Headers"
@v-yingjl Gracias por la respuesta. Basado en mi publicación anterior, creo que las consultas fallarían allí en lugar de cuando combino las consultas (páginas) juntos?
¿Alguna idea sobre cómo implementar esto?
@nobodyukno puede compartir el código M que está utilizando y pondré la lógica para detectar el error.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.