R
Rob Bickley
I have a real brain teaser. I have a table of data which I would like
to sum but the criteria to sum by can change based on 3 options:
1. Use columns A-1 to A-3 soley
2. Use columns B-1 to B-3 soley
3. Use both columns
The criteria changes to specify which A or B columns to use...but
only one at a time.
The reference in A29 varies depening on the option selection - 1,2 or
3.
Option 1 - INDIRECT($B$17)=$D$17) in this exanple is France
Option 2 - INDIRECT($B$18)=$D$18) is Test
Option 3 - uses both so France and Test.
My problem is that the formula is large but I cannot find a way to
make it more efficient. Ideally I want a test of which option is used
which and then it will use INDIRECT($B$17)=$D$17) or
INDIRECT($B$18)=$D$18) or both. I have tried to show a blank in the
criteria table (ie. France would be blank if Option 2 selected....but
it just returns a Zero since there are no blank cells in my table.
Ideally I need to use <> if a blank value but I cannot see a way to
vary between = or <>.
Any help gratefully received.
Thanks
Rob
My formula;
=CHOOSE($A$29,SUMPRODUCT((INDIRECT($B$17)=$D$17)*(Period<=D20)*(Period>=D21)*($J$4:$L$4=$D$19)*($J$6:$L$14)),SUMPRODUCT((INDIRECT($B$18)=$D$18)*(Period<=D20)*(Period>=D21)*($J$4:$L$4=$D$19)*($J$6:$L$14)),SUMPRODUCT((INDIRECT($B$17)=$D$17)*(INDIRECT($B$18)=$D$18)*(Period<=D20)*(Period>=D21)*($J$4:$L$4=$D$19)*($J$6:$L$14)))
My Table;
Col A-1 is excel col. B to 600010 is col.J
Col A-1 Col A-2 Col A-3 Col B-1 Col B-2 Col B-3 Col B-4 PERIOD Account
ALL Britain B010 GLOBAL GBU CUO ACTU 1 56,149
ALL France FR010 GLOBAL TEST CUO TEST 10 78,004
ALL Britain B020 GLOBAL GBU CUO ACTU 11 72,513
ALL Britain B010 GLOBAL GBU CUO TEST 12 (128,214)
ALL Britain B010 GLOBAL GBU TEST ACTU 2 56,423
ALL France FR020 GLOBAL GBU CUO ACTU 3 (95,960)
ALL Spain SP010 GLOBAL GBU CUO ACTU 4 56,881
ALL Spain SP011 GLOBAL GBU CUO ACTU 5 56,881
My criteria;
Col A-2 France
Col B-4 TEST
Period 10
Period 4
to sum but the criteria to sum by can change based on 3 options:
1. Use columns A-1 to A-3 soley
2. Use columns B-1 to B-3 soley
3. Use both columns
The criteria changes to specify which A or B columns to use...but
only one at a time.
The reference in A29 varies depening on the option selection - 1,2 or
3.
Option 1 - INDIRECT($B$17)=$D$17) in this exanple is France
Option 2 - INDIRECT($B$18)=$D$18) is Test
Option 3 - uses both so France and Test.
My problem is that the formula is large but I cannot find a way to
make it more efficient. Ideally I want a test of which option is used
which and then it will use INDIRECT($B$17)=$D$17) or
INDIRECT($B$18)=$D$18) or both. I have tried to show a blank in the
criteria table (ie. France would be blank if Option 2 selected....but
it just returns a Zero since there are no blank cells in my table.
Ideally I need to use <> if a blank value but I cannot see a way to
vary between = or <>.
Any help gratefully received.
Thanks
Rob
My formula;
=CHOOSE($A$29,SUMPRODUCT((INDIRECT($B$17)=$D$17)*(Period<=D20)*(Period>=D21)*($J$4:$L$4=$D$19)*($J$6:$L$14)),SUMPRODUCT((INDIRECT($B$18)=$D$18)*(Period<=D20)*(Period>=D21)*($J$4:$L$4=$D$19)*($J$6:$L$14)),SUMPRODUCT((INDIRECT($B$17)=$D$17)*(INDIRECT($B$18)=$D$18)*(Period<=D20)*(Period>=D21)*($J$4:$L$4=$D$19)*($J$6:$L$14)))
My Table;
Col A-1 is excel col. B to 600010 is col.J
Col A-1 Col A-2 Col A-3 Col B-1 Col B-2 Col B-3 Col B-4 PERIOD Account
ALL Britain B010 GLOBAL GBU CUO ACTU 1 56,149
ALL France FR010 GLOBAL TEST CUO TEST 10 78,004
ALL Britain B020 GLOBAL GBU CUO ACTU 11 72,513
ALL Britain B010 GLOBAL GBU CUO TEST 12 (128,214)
ALL Britain B010 GLOBAL GBU TEST ACTU 2 56,423
ALL France FR020 GLOBAL GBU CUO ACTU 3 (95,960)
ALL Spain SP010 GLOBAL GBU CUO ACTU 4 56,881
ALL Spain SP011 GLOBAL GBU CUO ACTU 5 56,881
My criteria;
Col A-2 France
Col B-4 TEST
Period 10
Period 4