Aggregate function with and/or criteria

ExcelNewbie2020

Active Member
Joined
Dec 3, 2020
Messages
343
Office Version
  1. 365
Platform
  1. Windows
Sirs,

i created this aggregate formula but seems i am missing something.
=IFERROR(INDEX($A$2:$C$23,AGGREGATE(15,6,(ROW($A$2:$A$23)-ROW($A$2)+1)/(($B$2:$B$23<>0)+(($C$2:$C$23<>0)))+(($B$2:$B$23<>0)*(($C$2:$C$23<>0))),ROWS($F$3:F3)),COLUMNS($F$3:F3)),"")

this condition "(($B$2:$B$23<>0)+(($C$2:$C$23<>0)))+(($B$2:$B$23<>0)*(($C$2:$C$23<>0)))" should extract non zero values but it didn't.. please help to modify this formula to make it work based on the expected result. thank you

Book1
ABCDEFGHIJKLMN
1CODEDEBITCREDITEXPECTED RESULT
2AB-7711000CODEDEBITCREDITCODEDEBITCREDIT
3AB-416450AB-7711000AB-7711000
4AB-116044AB-416450AB-416450
5AB-310069AB-116044AB-116044
6AB-52721AB-116044AB-310069
7AB-44103AB-310069AB-52721
8AB-50400AB-44103AB-44103
9AB-70100AB-44103AB-7751011
10AB-79800AB-50400AB-9439036
11AB-13000AB-3201000AB-3201000
12AB-7751011AB-412480AB-412480
13AB-9439036AB-830780AB-830780
14AB-3201000AB-864680AB-864680
15AB-412480AB-936710AB-936710
16AB-830780AB-754059AB-754059
17AB-864680AB-958024AB-958024
18AB-936710AB-941088AB-941088
19AB-754059AB-277045AB-277045
20AB-958024AB-888075AB-888075
21AB-941088
22AB-277045
23AB-888075
Sheet1
Cell Formulas
RangeFormula
F3:H20F3=IFERROR(INDEX($A$2:$C$23,AGGREGATE(15,6,(ROW($A$2:$A$23)-ROW($A$2)+1)/(($B$2:$B$23<>0)+(($C$2:$C$23<>0)))+(($B$2:$B$23<>0)*(($C$2:$C$23<>0))),ROWS($F$3:F3)),COLUMNS($F$3:F3)),"")
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Book1
ABCDEFGHIJKLMN
1CODEDEBITCREDITformulaEXPECTED RESULT
2AB-7711000CODEDEBITCREDITCODEDEBITCREDIT
3AB-416450AB-7711000AB-7711000
4AB-116044AB-416450AB-416450
5AB-310069AB-116044AB-116044
6AB-52721AB-310069AB-310069
7AB-44103AB-52721AB-52721
8AB-50400AB-44103AB-44103
9AB-70100AB-7751011AB-7751011
10AB-79800AB-9439036AB-9439036
11AB-13000AB-3201000AB-3201000
12AB-7751011AB-412480AB-412480
13AB-9439036AB-830780AB-830780
14AB-3201000AB-864680AB-864680
15AB-412480AB-936710AB-936710
16AB-830780AB-754059AB-754059
17AB-864680AB-958024AB-958024
18AB-936710AB-941088AB-941088
19AB-754059AB-277045AB-277045
20AB-958024AB-888075AB-888075
21AB-941088   
22AB-277045   
23AB-888075   
Sheet1
Cell Formulas
RangeFormula
F3:H23F3=IFERROR(INDEX($A$2:$C$23,AGGREGATE(15,6,(ROW($A$2:$A$23)-ROW($A$2)+1)/(($B$2:$B$23<>0)+($C$2:$C$23<>0)>0),ROWS($F$3:F3)),COLUMNS($F$3:F3)),"")
 
Upvote 0
Solution
Book1
ABCDEFGHIJKLMN
1CODEDEBITCREDITformulaEXPECTED RESULT
2AB-7711000CODEDEBITCREDITCODEDEBITCREDIT
3AB-416450AB-7711000AB-7711000
4AB-116044AB-416450AB-416450
5AB-310069AB-116044AB-116044
6AB-52721AB-310069AB-310069
7AB-44103AB-52721AB-52721
8AB-50400AB-44103AB-44103
9AB-70100AB-7751011AB-7751011
10AB-79800AB-9439036AB-9439036
11AB-13000AB-3201000AB-3201000
12AB-7751011AB-412480AB-412480
13AB-9439036AB-830780AB-830780
14AB-3201000AB-864680AB-864680
15AB-412480AB-936710AB-936710
16AB-830780AB-754059AB-754059
17AB-864680AB-958024AB-958024
18AB-936710AB-941088AB-941088
19AB-754059AB-277045AB-277045
20AB-958024AB-888075AB-888075
21AB-941088   
22AB-277045   
23AB-888075   
Sheet1
Cell Formulas
RangeFormula
F3:H23F3=IFERROR(INDEX($A$2:$C$23,AGGREGATE(15,6,(ROW($A$2:$A$23)-ROW($A$2)+1)/(($B$2:$B$23<>0)+($C$2:$C$23<>0)>0),ROWS($F$3:F3)),COLUMNS($F$3:F3)),"")
that worx.. thank you
 
Upvote 0
Another more modern way of handling this is to use the new(ish) FILTER function. It's much cleaner than its predecessor.

Excel Formula:
=FILTER(A1:C23,(B1:B23<>0)+(C1:C23<>0))
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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