strangebiscuit
New Member
- Joined
- Nov 25, 2013
- Messages
- 35
Sorry if the title is a bit obtuse...little hard to explain.
I'm trying to come up with a single sum formula that evaluates each cell in a column and adds a specific value to the sum based on the contents of that cell and two other cells in the same row. Here's an example table:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Utility[/TD]
[TD]Status[/TD]
[TD]Usage[/TD]
[/TR]
[TR]
[TD]power[/TD]
[TD]good[/TD]
[TD]1200[/TD]
[/TR]
[TR]
[TD]gas[/TD]
[TD]good[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]power[/TD]
[TD]bad[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]power[/TD]
[TD]good[/TD]
[TD]2500[/TD]
[/TR]
[TR]
[TD]gas[/TD]
[TD]good[/TD]
[TD]800[/TD]
[/TR]
</tbody>[/TABLE]
What I'd want in this situation is a single cell at the bottom with a formula in it that looks at each row, checks to see that the status is "good" and if so adds the following condition-based values to a total:
if the Utility is "power" and Usage >= 1000, add +5 to the total
if the Utility is "power" and Usage >= 2000, add +10 to the total
if the Utility is "gas" and Usage >= 300, add +5 to the total
if the Utility is "gas" and Usage >= 500, add +10 to the total
So in this case the total would be 30 (5+5+0+10+10).
This is just a simplified example, but I think if I had a sense of how to accomplish this (if it's even possible) I could expand it to fit other conditions.
I've done something similar in the past using SUMIFS, but in that case I was actually summing the values in the cells rather than summing other values inserted based on the values of the cell.
Again, I'm looking for a standalone formula rather than a formula per-row in a separate column or something based on a pivot table, etc... I know I could create another column and use nested IFs, i.e. something like
and drag it down the column and then get a sum of that column. But a formula in a single cell would be much more desirable.
Obviously, it could be done in VBA as well, but it needs to be live updating so a formula seems better.
If anybody has any tips as to what functions I could combine to create this, it'd be super helpful and greatly appreciated. Or if someone can confirm that's impossible to do as a standalone formula, that'd be helpful too!
Thanks in advance for your assistance/advice!
I'm trying to come up with a single sum formula that evaluates each cell in a column and adds a specific value to the sum based on the contents of that cell and two other cells in the same row. Here's an example table:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Utility[/TD]
[TD]Status[/TD]
[TD]Usage[/TD]
[/TR]
[TR]
[TD]power[/TD]
[TD]good[/TD]
[TD]1200[/TD]
[/TR]
[TR]
[TD]gas[/TD]
[TD]good[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]power[/TD]
[TD]bad[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]power[/TD]
[TD]good[/TD]
[TD]2500[/TD]
[/TR]
[TR]
[TD]gas[/TD]
[TD]good[/TD]
[TD]800[/TD]
[/TR]
</tbody>[/TABLE]
What I'd want in this situation is a single cell at the bottom with a formula in it that looks at each row, checks to see that the status is "good" and if so adds the following condition-based values to a total:
if the Utility is "power" and Usage >= 1000, add +5 to the total
if the Utility is "power" and Usage >= 2000, add +10 to the total
if the Utility is "gas" and Usage >= 300, add +5 to the total
if the Utility is "gas" and Usage >= 500, add +10 to the total
So in this case the total would be 30 (5+5+0+10+10).
This is just a simplified example, but I think if I had a sense of how to accomplish this (if it's even possible) I could expand it to fit other conditions.
I've done something similar in the past using SUMIFS, but in that case I was actually summing the values in the cells rather than summing other values inserted based on the values of the cell.
Again, I'm looking for a standalone formula rather than a formula per-row in a separate column or something based on a pivot table, etc... I know I could create another column and use nested IFs, i.e. something like
Code:
=IF(B2 = "good", IF(A2="power", IF(C2 >= 2000, 10, IF(C2 >= 1000, 5, 0)), IF(C2 >= 500, 10, IF(C2 >= 300, 5, 0))), 0)
Obviously, it could be done in VBA as well, but it needs to be live updating so a formula seems better.
If anybody has any tips as to what functions I could combine to create this, it'd be super helpful and greatly appreciated. Or if someone can confirm that's impossible to do as a standalone formula, that'd be helpful too!
Thanks in advance for your assistance/advice!
Last edited: