Rank only visible values and ignore zeros

Amba1006

New Member
Joined
Mar 24, 2023
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
I am trying to find a formula that will both rank only visible values but as the same time as ignoring zeros. I have an array formula for ranking only visible and I have a formula for for ignoring zeros but can not work out a formula to include both. Please help
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You can combine the two formulas to rank only the visible values while ignoring zeros by using the SUBTOTAL function in Excel. The SUBTOTAL function can perform calculations like SUM, AVERAGE, COUNT, etc. on visible cells only.
Here's an example formula to rank the values in column A while ignoring zeros:
=IF(A2=0,"",IFERROR(RANK.AVG(SUBTOTAL(9,OFFSET(A$1,ROW(A2:A10)-ROW(A2),)),SUBTOTAL(9,OFFSET(A$1,ROW(A2:A10)-ROW(A2),))),"-"))
In this formula, SUBTOTAL(9,OFFSET(A$1,ROW(A2:A10)-ROW(A2),)) is used to get the visible cells only in the range A2:A10. The RANK.AVG function is then used to rank the values in the visible cells.
The IF statement at the beginning checks if the value in A2 is zero. If it is, the cell is left blank. If not, the ranking is calculated as described above.
You can adjust the formula to fit your specific data range and requirements.
 
Upvote 0
You can combine the two formulas to rank only the visible values while ignoring zeros by using the SUBTOTAL function in Excel. The SUBTOTAL function can perform calculations like SUM, AVERAGE, COUNT, etc. on visible cells only.
Here's an example formula to rank the values in column A while ignoring zeros:
=IF(A2=0,"",IFERROR(RANK.AVG(SUBTOTAL(9,OFFSET(A$1,ROW(A2:A10)-ROW(A2),)),SUBTOTAL(9,OFFSET(A$1,ROW(A2:A10)-ROW(A2),))),"-"))
In this formula, SUBTOTAL(9,OFFSET(A$1,ROW(A2:A10)-ROW(A2),)) is used to get the visible cells only in the range A2:A10. The RANK.AVG function is then used to rank the values in the visible cells.
The IF statement at the beginning checks if the value in A2 is zero. If it is, the cell is left blank. If not, the ranking is calculated as described above.
You can adjust the formula to fit your specific data range and requirements.
Thanks so much however, I have entered the formula exactly as you have written it however it returns the below. I have walked through your formula and I can't see where that would apply. Any advice?
1679685190113.png
 
Upvote 0
Can you post some sample data, including your existing formulae.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Can you post some sample data, including your existing formulae.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Thanks, I am super new here. I will post example shortly
 
Upvote 0
Can you post some sample data, including your existing formulae.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Rank Formula Example.xlsx
ABCD
1COLOUR BANDYTD REVENUERank Ignoring ZEROFILTERED RANK
2BLUE£ 1,4012424
3GREEN£ 873,78966
4RED£ 9,846,46911
5BLUE£ 199,33799
6GREEN£ 13030
7RED£ 4,655,19533
8BLUE£ 2,879,57744
9GREEN£ 2,704,33555
10RED£ 140,4031010
11BLUE£ 7,138,34622
12GREEN£ 6022828
13RED£ - 31
14BLUE£ - 31
15GREEN£ - 31
16RED£ 6242727
17BLUE£ - 31
18GREEN£ - 31
19RED£ 12,6361313
20BLUE£ - 31
21GREEN£ - 31
22RED£ 13,0141212
23BLUE£ - 31
24GREEN£ 4522929
25RED£ 5,6311818
26BLUE£ 492,34977
27GREEN£ 9,4331717
28RED£ 2,6732020
29BLUE£ 2,6502121
30GREEN£ 9782525
31RED£ 11,0721515
32BLUE£ 11,7531414
33GREEN£ 319,00588
34RED£ 4,3641919
35BLUE£ 1,6552323
36GREEN£ 2,4942222
37RED£ 7472626
38BLUE£ 10,3451616
39GREEN£ 112,4171111
RANK FORMULA
Cell Formulas
RangeFormula
C2:C39C2=IF([@[YTD REVENUE]]=0,"",SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B2<$B$2:$B$39,1)))+1)
D2:D39D2=SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B2<$B$2:$B$39,1)))+1
 
Upvote 0
Rank Formula Example.xlsx
ABCD
1COLOUR BANDYTD REVENUERank Ignoring ZEROFILTERED RANK
2BLUE£ 1,4012424
3GREEN£ 873,78966
4RED£ 9,846,46911
5BLUE£ 199,33799
6GREEN£ 13030
7RED£ 4,655,19533
8BLUE£ 2,879,57744
9GREEN£ 2,704,33555
10RED£ 140,4031010
11BLUE£ 7,138,34622
12GREEN£ 6022828
13RED£ - 31
14BLUE£ - 31
15GREEN£ - 31
16RED£ 6242727
17BLUE£ - 31
18GREEN£ - 31
19RED£ 12,6361313
20BLUE£ - 31
21GREEN£ - 31
22RED£ 13,0141212
23BLUE£ - 31
24GREEN£ 4522929
25RED£ 5,6311818
26BLUE£ 492,34977
27GREEN£ 9,4331717
28RED£ 2,6732020
29BLUE£ 2,6502121
30GREEN£ 9782525
31RED£ 11,0721515
32BLUE£ 11,7531414
33GREEN£ 319,00588
34RED£ 4,3641919
35BLUE£ 1,6552323
36GREEN£ 2,4942222
37RED£ 7472626
38BLUE£ 10,3451616
39GREEN£ 112,4171111
RANK FORMULA
Cell Formulas
RangeFormula
C2:C39C2=IF([@[YTD REVENUE]]=0,"",SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B2<$B$2:$B$39,1)))+1)
D2:D39D2=SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B2<$B$2:$B$39,1)))+1
So I have just added column A to show that the formula in column D works on filters but basically I am trying to combine the two formulas (or a formula that does the job of both)
 
Upvote 0
Must admit I'm not sure what your asking for as both formulae return the same result, except for the zeros.
But if you are happy with a helper column, you can get rid of the volatile functions
Fluff.xlsm
ABCDEF
1COLOUR BANDYTD REVENUERank Ignoring ZEROFILTERED RANKIsVisibleColumn2
2BLUE1401.052424124
3GREEN873789.3376616
4RED9846469.341111
5BLUE199336.7279919
6GREEN0.653030130
7RED4655195.0213313
8BLUE2879577.4464414
9GREEN2704335.2095515
10RED140402.621010110
11BLUE7138346.1562212
12GREEN602.12828128
13RED0 311 
14BLUE0 311 
15GREEN0 311 
16RED623.712727127
17BLUE0 311 
18GREEN0 311 
19RED12636.1621313113
20BLUE0 311 
21GREEN0 311 
22RED13014.31212112
23BLUE0 311 
24GREEN451.622929129
25RED5631.221818118
26BLUE492349.3517717
27GREEN9433.1661717117
28RED2672.912020120
29BLUE2649.682121121
30GREEN977.82525125
31RED11071.751515115
32BLUE11752.591414114
33GREEN319004.748818
34RED4364.131919119
35BLUE1654.52323123
36GREEN2494.352222122
37RED746.912626126
38BLUE10345.111616116
39GREEN112417.091111111
Sheet4
Cell Formulas
RangeFormula
C2:C39C2=IF([@[YTD REVENUE]]=0,"",SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B2<$B$2:$B$39,1)))+1)
D2:D39D2=SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B2<$B$2:$B$39,1)))+1
E2:E39E2=SUBTOTAL(103,[@[COLOUR BAND]])
F2:F39F2=IF([@[YTD REVENUE]]=0,"",COUNTIFS([YTD REVENUE],">"&[@[YTD REVENUE]],[IsVisible],1)+1)


Fluff.xlsm
ABCDEF
1COLOUR BANDYTD REVENUERank Ignoring ZEROFILTERED RANKIsVisibleColumn2
3GREEN873789.3372212
6GREEN0.651010110
9GREEN2704335.2091111
12GREEN602.18818
15GREEN0 111 
18GREEN0 111 
21GREEN0 111 
24GREEN451.629919
27GREEN9433.1665515
30GREEN977.87717
33GREEN319004.743313
36GREEN2494.356616
39GREEN112417.094414
Sheet4
Cell Formulas
RangeFormula
C3,C6,C9,C12,C15,C18,C21,C24,C27,C30,C33,C36,C39C3=IF([@[YTD REVENUE]]=0,"",SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B3<$B$2:$B$39,1)))+1)
D3,D6,D9,D12,D15,D18,D21,D24,D27,D30,D33,D36,D39D3=SUM(IF(SUBTOTAL(103,OFFSET($B$2:$B$39,ROW($B$2:$B$39)-ROW($B$2),0,1))>0,IF(B3<$B$2:$B$39,1)))+1
E3,E6,E9,E12,E15,E18,E21,E24,E27,E30,E33,E36,E39E3=SUBTOTAL(103,[@[COLOUR BAND]])
F3,F6,F9,F12,F15,F18,F21,F24,F27,F30,F33,F36,F39F3=IF([@[YTD REVENUE]]=0,"",COUNTIFS([YTD REVENUE],">"&[@[YTD REVENUE]],[IsVisible],1)+1)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,375
Messages
6,124,576
Members
449,173
Latest member
Kon123

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