Forum

Notifications
Clear all

random sum of values in excel Table

7 Posts
3 Users
0 Reactions
171 Views
(@anil_dube)
Posts: 4
Active Member
Topic starter
 
x 2 x 2 x 5 y 2
y 1 y 2 x 3 x 1
               
    sum of all x          
    sum of all y          
 
Posted : 19/09/2019 2:47 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Anil,

Welcome to our forum! Please upload an Excel file containing your data and desired result and explain in words what you're after as I'm not sure what the above is asking.

Many thanks,

Mynda

 
Posted : 19/09/2019 5:57 am
(@anil_dube)
Posts: 4
Active Member
Topic starter
 

In the attached sample file, x & y being variables are distributed in the table. The No written in front of variable is the value of that variable. USING excel functions , I want to sum up all the values for x and all the values for y. Example for all the Xs the sum is 13 and all the Ys sum up to 5 in the attached file. 

 
Posted : 20/09/2019 2:59 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Anil,

Try: =SUMPRODUCT(IFERROR((C12:I13)/ (B12:H13="x"),0))

=SUMPRODUCT(IFERROR((C12:I13)/ (B12:H13="y"),0))

 
Posted : 20/09/2019 5:27 am
(@anil_dube)
Posts: 4
Active Member
Topic starter
 

Simply, Marvelous. Working perfectly. I entered the formula as "Array Formula" by "CTRL+SHIFT"..ENTER.

Working. But giving 0 if we do not enter as array formula.

Thanks, Really obliged ...

 
Posted : 21/09/2019 3:05 am
(@anil_dube)
Posts: 4
Active Member
Topic starter
 

Further, you are kindly requested to explain, How this overall formula works please.

That will be a great help !

thanks & great regards.

 
Posted : 21/09/2019 3:10 am
(@catalinb)
Posts: 1937
Member Admin
 

B12:H13="y" will produce an array of True and False values, there will be one true/false value for each cell in the range.

If you divide the next cell by the true/false values: (C12:I13)/ (B12:H13="y"), the ones without a "y" will produce an error, because dividing by a False value is equal to dividing a number by zero. Same with the values tat passes the evaluation: dividing a cell by True is equal to dividing by 1, the current values from C11:I13 will remain unchanged after division. Iferror will just replace errors with zero, to allow SUMPRODUCT to finish adding the values that passed the evaluation.

 
Posted : 21/09/2019 12:19 pm
Share: