How to Check whether a Table is Filtered or not using Formulas
Let us start the week with a simple formula (well, to be fair, let us start the week with a strong cup of coffee, then this formula).
Often when we have large data sets, we apply data filters to select and display only information we want to see.
Some of you know that whenever we apply filters on a dataset, we can look at status bar area to find out if any filter is applied on the current worksheet. It looks like this when filters are applied:
But, what if you need a way to show “filtering” status thru formulas?
Well, you can do that very easily by using two simple formulas called as COUNTA() and SUBTOTAL().
Here is how it works:
And the formula is, (assuming we want to test the range B4:B3000)
=IF(COUNTA(B4:B3000)>SUBTOTAL(3,B4:B3000), "list filtered ["&SUBTOTAL(3,B4:B3000)&" items]","Not filtered")
How does the formula work?
- We are asking excel to findout how many values are there in the range B4:B3000 using COUNTA() formula.
- Then we are asking excel to tell how many values are there after filter in the same range using SUBTOTAL() formula [introduction to excel SUBTOTAL formula].
- Now, if the first value is more than second, we knew that the list is filtered. So we are showing a message like,
- “List Filtered [x items]”.
What would you use this type of formula for?
I have used this type of formula in charts, dashboards where I need to tell whether source data is filtered or complete. What about you? Where would you use this type of formula?
Leave a Reply
|What do you use Excel for? [Weekend Poll]||Making a Dynamic Dashboard in Excel [Part 2 of 4]|