Filter Function - Blank cells return as 0

FrankieGTH

New Member
Joined
May 29, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I'm using the Filter function on a table that has blank cells. When I use the function, blank cells return as 0. Ideally, I'd like the 0s not to be there and the filter returns blank cells as blank.

In an epic fail, I tried to use the substitute function, substituting "0" for "", however this chops off 0s from the hours column (30 becomes 3, etc). It feels that should be a way to do this, but my brain is failing. Would anyone be able to conjure up a formula to replace these 0s? I'd like to avoid using conditional formatting if possible.

Book1
ABCDEFGHI
1StaffDepartmentFire TrainedHours Per WeekPurachildrenswearNo17
2PurachildrenswearNo17LeorachildrenswearYes25
3LeorachildrenswearYes25Audreychildrenswear00
4AudreychildrenswearMartichildrenswearYes22
5GwendawomenswearNo10MaryettachildrenswearYes18
6JaneemenswearNo28Salomechildrenswear020
7WarrenmenswearNo17RegeniachildrenswearYes26
8ShantelmenswearNo20Yungchildrenswear030
9RachelmenswearYes29
10MartichildrenswearYes22PurachildrenswearNo17
11MaryettachildrenswearYes18LeorachildrenswearYes25
12BrandawomenswearYes19Audreychildrenswear
13BoydmenswearNo26MartichildrenswearYes22
14VadamenswearYes29MaryettachildrenswearYes18
15LowellmenswearNo25Salomechildrenswear2
16KristinamenswearYes14RegeniachildrenswearYes26
17BeckiwomenswearYes36Yungchildrenswear3
18Salomechildrenswear20
19LourawomenswearNo26
20RegeniachildrenswearYes26
21Yungchildrenswear30
Sheet1
Cell Formulas
RangeFormula
F1:I8F1=FILTER($A$1:$D$21,$B$1:$B$21="childrenswear")
F10:I17F10=SUBSTITUTE(FILTER($A$1:$D$21,$B$1:$B$21="childrenswear"),"0","")
Dynamic array formulas.


Sincerest thanks.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If you have the LET function
Excel Formula:
=LET(f,FILTER($A$1:$D$21,$B$1:$B$21="childrenswear"),IF(f=0,"",f))
If you don't have it,
Excel Formula:
=IF(FILTER($A$1:$D$21,$B$1:$B$21="childrenswear")=0,"",FILTER($A$1:$D$21,$B$1:$B$21="childrenswear"))

Effectively 2 versions of the same formula, it's just slightly more efficient using LET.
 
Upvote 0
Solution
Another option
+Fluff 1.xlsm
ABCDEFGHI
1StaffDepartmentFire TrainedHours Per WeekPurachildrenswearNo17
2PurachildrenswearNo17LeorachildrenswearYes25
3LeorachildrenswearYes25Audreychildrenswear
4AudreychildrenswearMartichildrenswearYes22
5GwendawomenswearNo10MaryettachildrenswearYes18
6JaneemenswearNo28Salomechildrenswear20
7WarrenmenswearNo17RegeniachildrenswearYes26
8ShantelmenswearNo20Yungchildrenswear30
9RachelmenswearYes29
10MartichildrenswearYes22
11MaryettachildrenswearYes18
12BrandawomenswearYes19
13BoydmenswearNo26
14VadamenswearYes29
15LowellmenswearNo25
16KristinamenswearYes14
17BeckiwomenswearYes36
18Salomechildrenswear20
19LourawomenswearNo26
20RegeniachildrenswearYes26
21Yungchildrenswear30
22
Main
Cell Formulas
RangeFormula
F1:I8F1=FILTER(IF(ISNUMBER($A$1:$D$21),A1:D21,A1:D21&""),$B$1:$B$21="childrenswear")
Dynamic array formulas.
 
Upvote 0
Thank you both very much indeed. @Fluff's answer I can understand, I really need to get to grips with the LET function @jasonb75 as it seems very useful.

Wishing you a peaceful weekend.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
I really need to get to grips with the LET function @jasonb75 as it seems very useful.
It is very useful, and very simple once you understand how it works. If you understand basic vba, think of LET as being the formula equivalent to variables.

In the longer version of my suggested formula the FILTER function is used twice with both instances being identical. Because it is used twice it has to be calculated twice, even though we know that the results will be the same both times.

Using LET to assign the FILTER section of the formula to a name / variable means that it only needs to be calculated once because we can use the name / variable to refer to the results of the first calculation rather than performing the calculation each time.

Not much difference here as it is only one extra calculation on a small array, but with a large array that is repeated 4 or 5 times in a single formula there can be a big improvement in calculation time.
 
Upvote 0

Forum statistics

Threads
1,215,522
Messages
6,125,312
Members
449,218
Latest member
Excel Master

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