SUMPRODUCT or product within SUMIF with multiple criterion and IF statements.

n8te

New Member
Joined
Feb 13, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi there,

While I'm quite able to write some decent code in VBA, I do not really know why but I still meet difficulties coding cells formula.

Here is a SUMIF formula I have:

Excel Formula:
=SUMIFS(INDIRECT("tableA["var" & LEFT(narea1;FIND(" ";narea1) -1) &"]");   
tableA[P_ID];IF([@P_ID]="all";"<>";MATCH([@P];tablec[varname];0));
tableA[T_ID];IF([@T_ID]="all";"<>";VLOOKUP([@T_ID];narea2;2));tableA[Y_ID];
IF([@Y_ID]="all";"<>";[@Y_ID]))

Basically, in table A, I want my formula to sum conditionally amounts in table b based on info retrievable from table A, C or 2 different named areas. This formula works such fine.
I realized however that I made a theoretical mistake and I want to weight the amounts in table b with an another variable in the same table with the same condition.

I think then that I need a sumproduct function but I do not understand how to integrate the different criteria in it. Anyone has an idea how to adapt this formula to a sumproduct ?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I made some improvements and I found a way to get the sumproduct. However I still having some trouble with the nested If statements.

Here is my new formula:

Excel Formula:
=SUMPRODUCT(INDIRECT("tableA[var & LEFT(a_cost;FIND(" "narea1) -1) &"]");(tableA[P_ID]=IF([@P_ID]="all";;MATCH([@P_ID];tablec[varname];0)))*(tableA[T_ID]=IF([@T_ID]="all";;VLOOKUP([@T_ID];narea2e;2)))*(tableA[Y_ID]=IF([@Y_ID]="all";;[@Y_ID])))

I want the formula to sumproduct variables in a table A (for now, only one array is specified) based on conditions based on table B. As you can see on the screenshot herebelow, the formula only works when there is not one condition that contains the "All" item.

1677770028419.png


I don't know how to specify in the IF statement that there should be no conditions when the "ALL" statements appear.

I still don't know if my request is understandable :/
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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