VSTACK not ignoring blanks

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
677
Office Version
  1. 365
Platform
  1. MacOS
Hi,

I have a VSTACK formula, that had up until now appeared to have been working. However, now that my data has changed slightly I have encountered an issue. My formula is as below:

Excel Formula:
=IFERROR(SORT(VSTACK(FILTER('All Completed Runs - EC (SA)'!A4:A2003,'All Completed Runs - EC (SA)'!A4:A2003<>""),FILTER('All Completed Runs - FS (SA)'!A4:A2003,'All Completed Runs - FS (SA)'!A4:A2003<>""),FILTER('All Completed Runs - GT (SA)'!A4:A2003,'All Completed Runs - GT (SA)'!A4:A2003<>""),FILTER('All Completed Runs - KZN (SA)'!A4:A2003,'All Completed Runs - KZN (SA)'!A4:A2003<>""),FILTER('All Completed Runs - LI R (SA)'!A4:A2003,'All Completed Runs - LI R (SA)'!A4:A2003<>""),FILTER('All Completed Runs - MP R (SA)'!A4:A2003,'All Completed Runs - MP R (SA)'!A4:A2003<>""),FILTER('All Completed Runs - NW R (SA)'!A4:A2003,'All Completed Runs - NW R (SA)'!A4:A2003<>""),FILTER('All Completed Runs - NC R (SA)'!A4:A2003,'All Completed Runs - NC R (SA)'!A4:A2003<>""),FILTER('All Completed Runs - WC (SA)'!A4:A2003,'All Completed Runs - WC (SA)'!A4:A2003<>"")),,,-1),"")

I thought that I had catered for ranges with no data via the <>"" in each filter function, but it doesn't seem to be working. Now that KZN (SA)'!A4:A2003 and NW R (SA)'!A4:A2003 don't currently have any data, the formula is not working. Do I need some sort filter wrapped around the entire thing, perhaps before the '(VSTACK' part of the formula?

If I remove the IFERROR function, I can see that it's a CALC error that I'm getting.

Thanks in advance!

Olly.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Stack the data & then filter it like
Excel Formula:
=let(v,VSTACK('All Completed Runs - EC (SA)'!A4:A2003,'All Completed Runs - FS (SA)'!A4:A2003,'All Completed Runs - GT (SA)'!A4:A2003)SORT(FILTER(v,v<>""),,-1))
 
Upvote 0
Solution
Try using the third argument in each of the FILTER functions, which will be useful for when a particular filter range has completely no data at all.
You might want to wrap the entire VSTACK with another FILTER to exclude blanks, probably after assigning the result of the VSTACK function to a variable in LET.

Perhaps something like

Excel Formula:
IFERROR(SORT(LET(_a,VSTACK(FILTER('All Completed Runs - EC (SA)'!A4:A2003,'All Completed Runs - EC (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - FS (SA)'!A4:A2003,'All Completed Runs - FS (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - GT (SA)'!A4:A2003,'All Completed Runs - GT (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - KZN (SA)'!A4:A2003,'All Completed Runs - KZN (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - LI R (SA)'!A4:A2003,'All Completed Runs - LI R (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - MP R (SA)'!A4:A2003,'All Completed Runs - MP R (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - NW R (SA)'!A4:A2003,'All Completed Runs - NW R (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - NC R (SA)'!A4:A2003,'All Completed Runs - NC R (SA)'!A4:A2003<>"",""),FILTER('All Completed Runs - WC (SA)'!A4:A2003,'All Completed Runs - WC (SA)'!A4:A2003<>"")),FILTER(_a,_a<>"")),,,-1),"")
 
Upvote 0
Stack the data & then filter it like
Excel Formula:
=let(v,VSTACK('All Completed Runs - EC (SA)'!A4:A2003,'All Completed Runs - FS (SA)'!A4:A2003,'All Completed Runs - GT (SA)'!A4:A2003)SORT(FILTER(v,v<>""),,-1))
Thanks. I am trying the below formula (which includes all of the ranges), but I'm getting an error. Have I made a typo?

Excel Formula:
=let(v,VSTACK('All Completed Runs - EC (SA)'!A4:A2003,'All Completed Runs - FS (SA)'!A4:A2003,'All Completed Runs - GT (SA)'!A4:A2003,'All Completed Runs - KZN (SA)'!A4:A2003,'All Completed Runs - LI R (SA)'!A4:A2003,'All Completed Runs - MP R (SA)'!A4:A2003,'All Completed Runs - NW R (SA)'!A4:A2003,'All Completed Runs - NC R (SA)'!A4:A2003,'All Completed Runs - WC (SA)'!A4:A2003)SORT(FILTER(v,v<>""),,-1))



Thanks.
 

Attachments

  • Screenshot 2023-06-12 at 12.20.17.jpg
    Screenshot 2023-06-12 at 12.20.17.jpg
    150.5 KB · Views: 20
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,153
Messages
6,123,325
Members
449,097
Latest member
gameover8

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