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

The 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.

Reply
Anonymous
Not applicable

Editor de consultas: ¿intenta consultar, si hay un error, omitir/mover?

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?

5 REPLIES 5
v-yingjl
Community Support
Community Support

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.

Anonymous
Not applicable

@parry2k

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"
Anonymous
Not applicable

@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?

Anonymous
Not applicable

¿Alguna idea sobre cómo implementar esto?

parry2k
Super User
Super User

@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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors