Merging two queries, error when one query has no data

Will85

Active Member
Joined
Apr 26, 2012
Messages
254
Office Version
  1. 365
Platform
  1. Windows
I have two tables in excel that I have connected too to create queries A & B. I have (left) joined queries A & B to create query C.

I have a pivot table that is connected to query C.

99% of the time both query A & B will always have data, but there are instances where, based on user selectable dynamic filters, query B might not have any data at all.

In these instances when I refresh the data, I get an error, and in power query, query C is showing one cell with an error, because there is no data in query B.

How can I force query C to still work, and perhpas display zeros for the all columns that were coming from query B?

Or, can I add some type of helper column to query B and hardcode some random value to always ensure there is data? ( I cannot add to the excel table itself)
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
There’s 2 general approaches. You can manually edit the M code using the try statement
try <your current code> otherwise <new code that doesn’t cause an error>

The other approach is to try to make it always work. What you do depends on the specifics, but you could try appending a single record to the table before the merge, then filter that record out after the merge. Just a guess.
 
Upvote 0

Forum statistics

Threads
1,226,079
Messages
6,188,773
Members
453,499
Latest member
samdan87153

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top