Merging two queries, error when one query has no data

Will85

Active Member
Joined
Apr 26, 2012
Messages
253
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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