Excel 2007
How do I make a multiple conditional formula have the ability to active/deactivate a certain condition dynamically.
The example below should clarify; I have the following formula:
=SUMPRODUCT((Building=$B15)*(Unit_Type=$B16)*(Unit_Line=H15),Rent_Month_Total)
This formula sums the total rent per month based on the Building, Unit_Type, and Unit Line (which are all defined ranges) I specify in cells B15, B16, and H15. However, in certain instances I need to deactivate the (Unit_Line=H15) criteria; essentially, I need to sum only the rent based on Building and Unit_Type and not Unit_Line (most common reason for this is because I don't have Unit_Line info).
My line of thinking to this problem was to create an 'if" condition for the condition I'd like to have the ability to turn off. I created an 'if' condition where 0 is "off" and not 0 is "on" (see red highlighted section of formula below). So, when the 'if' formula is false (or off) it simply produces a 1 which when entered into the sumproduct array does not do anything and essentially deactivates the condition. However, I'm having a difficult time getting the "on" part working, and activating the condition when I need it. My formula is shown below.
=SUMPRODUCT((Building=$B15)*(Unit_Type=$B16)*IF($I15<>0,"("&Unit_Line=$H15&")",1),Rent_Month_Total)
The I15 cell is the toggle that allows activating or deactivating the cell.
What am I doing wrong; why can't I activate the condition when needed? By the way, when I do active the condition the formula simple produces a zero. At least I'm not getting an error.
Also, I'm aware I can achieve the same thing with the 'sumifs' function, but I thought it would be easier with sumproduct as the '*' joiner makes it a bit cleaner when dealing with formula. However, if someone can achieve the same thing with the sumifs formula I'll use that in heartbeat since I think the sumifs are faster.
Thank you in advance.
-Henri
How do I make a multiple conditional formula have the ability to active/deactivate a certain condition dynamically.
The example below should clarify; I have the following formula:
=SUMPRODUCT((Building=$B15)*(Unit_Type=$B16)*(Unit_Line=H15),Rent_Month_Total)
This formula sums the total rent per month based on the Building, Unit_Type, and Unit Line (which are all defined ranges) I specify in cells B15, B16, and H15. However, in certain instances I need to deactivate the (Unit_Line=H15) criteria; essentially, I need to sum only the rent based on Building and Unit_Type and not Unit_Line (most common reason for this is because I don't have Unit_Line info).
My line of thinking to this problem was to create an 'if" condition for the condition I'd like to have the ability to turn off. I created an 'if' condition where 0 is "off" and not 0 is "on" (see red highlighted section of formula below). So, when the 'if' formula is false (or off) it simply produces a 1 which when entered into the sumproduct array does not do anything and essentially deactivates the condition. However, I'm having a difficult time getting the "on" part working, and activating the condition when I need it. My formula is shown below.
=SUMPRODUCT((Building=$B15)*(Unit_Type=$B16)*IF($I15<>0,"("&Unit_Line=$H15&")",1),Rent_Month_Total)
The I15 cell is the toggle that allows activating or deactivating the cell.
What am I doing wrong; why can't I activate the condition when needed? By the way, when I do active the condition the formula simple produces a zero. At least I'm not getting an error.
Also, I'm aware I can achieve the same thing with the 'sumifs' function, but I thought it would be easier with sumproduct as the '*' joiner makes it a bit cleaner when dealing with formula. However, if someone can achieve the same thing with the sumifs formula I'll use that in heartbeat since I think the sumifs are faster.
Thank you in advance.
-Henri
Last edited: