Formula help

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
166
Office Version
  1. 365
Platform
  1. Windows
i am trying to build a formula to do a calculation between 4 columns where any one of the values could be missing at any given time. I want the formula to only calculate when values are present. I know how to build using the if function but there are so many possible combinations that im not sure how to capture them all. If anyone knows of an easier way could you please help? The values of the cells are being returned via formula that cannot be removed (it would be so much simpler if i could). Here is a sample.... this does not reflect every single possible combination, just a sample.

column QColumn RColumns SColumn T
(Q)(R*3)(S*2)(T)<<calculation for each column
CountedMissingManualElectronicExpected Resultvvv calculation being performed
48122072((Q+(R*3))+((T+(S*2))
481252((Q+(R*3))+(S*2))
4828(Q+(R*3)
44Q
482048((Q+(R*3))+T)
4122048(Q+((T+(S*2))
82044((R*3)+T)
122044T+(S*2)
8122068((R*3)+((T+(S*2))
42024(Q+T)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
maybe i dont follow - but you are only multiplying 1 value at a time and that adding other - so if a cell is blank - it does not affect others

for example (Q2+R2)*S2 - if S2 is blank - it will multiply by zero, and so give a result of zero
if it was ignored then it would give Q2+R2



i just used
=((Q2+(R2*3))+((T2+(S2*2))))
and it gave all the expected results - see column Y with formula

perhaps i'm missing something

Book2
QRSTUVWXY
1CountedMissingManualElectronicExpected Resultvvv calculation being performed
248122072((Q+(R*3))+((T+(S*2))72
3481252((Q+(R*3))+(S*2))52
44828(Q+(R*3)28
544Q4
6482048((Q+(R*3))+T)48
74122048(Q+((T+(S*2))48
882044((R*3)+T)44
9122044T+(S*2)44
108122068((R*3)+((T+(S*2))68
1142024(Q+T)24
Sheet1
Cell Formulas
RangeFormula
Y2:Y11Y2=((Q2+(R2*3))+((T2+(S2*2))))
 
Upvote 0
maybe i dont follow - but you are only multiplying 1 value at a time and that adding other - so if a cell is blank - it does not affect others

for example (Q2+R2)*S2 - if S2 is blank - it will multiply by zero, and so give a result of zero
if it was ignored then it would give Q2+R2



i just used
=((Q2+(R2*3))+((T2+(S2*2))))
and it gave all the expected results - see column Y with formula

perhaps i'm missing something

Book2
QRSTUVWXY
1CountedMissingManualElectronicExpected Resultvvv calculation being performed
248122072((Q+(R*3))+((T+(S*2))72
3481252((Q+(R*3))+(S*2))52
44828(Q+(R*3)28
544Q4
6482048((Q+(R*3))+T)48
74122048(Q+((T+(S*2))48
882044((R*3)+T)44
9122044T+(S*2)44
108122068((R*3)+((T+(S*2))68
1142024(Q+T)24
Sheet1
Cell Formulas
RangeFormula
Y2:Y11Y2=((Q2+(R2*3))+((T2+(S2*2))))
correct. if the cells are blank then yes that would work. but mine are not blank, they have a formula in them so i get this...

48122072
4812-#VALUE!
48--#VALUE!
4---#VALUE!
48-20#VALUE!
4-1220#VALUE!
-8-20#VALUE!
--1220#VALUE!
-81220#VALUE!
4--20#VALUE!
 
Upvote 0
Helper column solution.

Book3
ABCDEFGHI
1column QColumn RColumns SColumn THelper RHelper S
2(Q)(R*3)(S*2)(T)<<calculation for each column
3CountedMissingManualElectronicResultExpected Resultvvv calculation being performed
448122024247272((Q+(R*3))+((T+(S*2))
5481224245252((Q+(R*3))+(S*2))
6482402828(Q+(R*3)
740044Q
848202404848((Q+(R*3))+T)
9412200244848(Q+((T+(S*2))
108202404444((R*3)+T)
1112200244444T+(S*2)
128122024246868((R*3)+((T+(S*2))
13420002424(Q+T)
Sheet1
Cell Formulas
RangeFormula
E4:E13E4=B4*3
F4:F13F4=C4*2
G4:G13G4=SUM(A4,D4,E4,F4)
 
Upvote 0
Helper column solution.

Book3
ABCDEFGHI
1column QColumn RColumns SColumn THelper RHelper S
2(Q)(R*3)(S*2)(T)<<calculation for each column
3CountedMissingManualElectronicResultExpected Resultvvv calculation being performed
448122024247272((Q+(R*3))+((T+(S*2))
5481224245252((Q+(R*3))+(S*2))
6482402828(Q+(R*3)
740044Q
848202404848((Q+(R*3))+T)
9412200244848(Q+((T+(S*2))
108202404444((R*3)+T)
1112200244444T+(S*2)
128122024246868((R*3)+((T+(S*2))
13420002424(Q+T)
Sheet1
Cell Formulas
RangeFormula
E4:E13E4=B4*3
F4:F13F4=C4*2
G4:G13G4=SUM(A4,D4,E4,F4)
I'll try that. Was really hoping for just a single formula rather that a helper column.
 
Upvote 0
I'll try that. Was really hoping for just a single formula rather that a helper column.
That would certainly be neater. On the other hand, this is much easier to understand if you need to come back to it later. You can also do this in Power Query, where you can erase the helper columns in the final product.
 
Upvote 0
The problem is those blanks are actually coming in as text. Using the basic operations (+,-,*,/) will result in errors, but functions can fix it.. I'd recommend something like =SUM(a4,D4)+PRODUCT(B4,3)+PRODUCT(C4,2)
 
Upvote 0
Solution
The problem is those blanks are actually coming in as text. Using the basic operations (+,-,*,/) will result in errors, but functions can fix it.. I'd recommend something like =SUM(a4,D4)+PRODUCT(B4,3)+PRODUCT(C4,2)
This is close. If the product (in your example B4 or C4) has a value it calculates correctly. But if there is no value to calculate then it returns a 3 or a 2 as a place holder to calculate.

countedmissingManualElectronicExpected Resultsum(A3,D3)+product(B3,3)+product(C3,2)
4812207272
48125252
482830
449
48204850
412204851
8204446
12204447
812206868
4202429
 
Upvote 0
I wasn't expecting that. This might be a option for columns B and C
Excel Formula:
=IFERROR(B4*3,0)+IFERROR(C4*2,0)
 
Upvote 0
I wasn't expecting that. This might be a option for columns B and C
Excel Formula:
=IFERROR(B4*3,0)+IFERROR(C4*2,0)
i was actually testing a theory and you beat me to the response. lol your original formulas was pretty darn close. Ive never used the product()function before so with a bit of research google suggested using sumproduct() instead to cancel out the non numeric values and return a 0 in that part of the calculation. this is the final solution. ive tested it every way i can think and applied to live data and everything seems to be checking out.

=sum(A3,D3)+sumproduct(B3,3)+sumproduct(C3,2)

im going to mark your formula as a solution since it pointed me in the direction i needed to be. thanks so much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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