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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PietroFarias
Resolver II
Resolver II

How to combine tables, one of which is returning an error?

Hello guys!

 

My help today is in the combination of 'Table.Combine' and 'try ... otherwise ...'.

I am performing a combination of tables in Power Query and one of the tables being combined comes from an "unstable" external connection. But I don't want to miss the combination because of this QUery. I would like to ignore this query in the combination if it represents an error. The code below is something I am trying to do. But as the combination needs to be of the TABLE type, so I got stuck in this part. I don't want to have to create an empty table using #table (), as this would leave the combination static.

Can someone help me?

let
    Source = 
    Table.Combine(
        {
            Query1,
            Query2,
            try Query3 otherwise null  //<<----
        }
    )
in
    Source

 

1 ACCEPTED SOLUTION

Hi @PietroFarias ,

I have modified the query like this you can refer:

 

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

 

query.png

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yingjl
Community Support
Community Support

Hi @PietroFarias ,

Maybe try to exchange the query order like this:

let
    Source = 
    Table.Combine(
        {
            try 
            Table.FindText()  //Query3 which represents an error
            otherwise
            Table.FromRecords({[CustomerID = 1, Name = "Bob"]}),  //Query1
            Table.FromRecords({[CustomerID = 2, Name = "Jim"]})   //Query2
        }
    )
in
    Source

power query combine.png

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

@v-yingjl,

In your example, if the first query does not generate an error, the Query1 will not be combined, it will come out of this combination.

Hi @PietroFarias ,

I have modified the query like this you can refer:

 

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

 

query.png

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Great!!

 

Good ideia use List.RemoveNulls.

Thanks!

amitchandak
Super User
Super User

@PietroFarias , refer this there is an example how to handle error in M

https://www.poweredsolutions.co/2019/06/18/error-handling-iferror-in-power-bi-power-query/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.