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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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