March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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
Solved! Go to 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
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.
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
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.
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
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!
@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/
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
86 | |
76 | |
57 | |
52 |
User | Count |
---|---|
201 | |
137 | |
108 | |
73 | |
68 |