fredericdenis
New Member
- Joined
- Mar 27, 2017
- Messages
- 3
Dear Excel gurus,
I feel this is possible, but I’m not familiar enough with Excel array formulas and pro uses of SUMPRODUCT function to find how to make it possible. I'm stuck and need your help.
Given a dynamic 2D range (result of an OFFSET function), I would like calculate a value for each column of that range, and pass that 1D array of values as an argument to the SUMPRODUCT function.
Specifically, each value of the 1D array would indicate if the corresponding column in the dynamic range had at least one non-empty cell (1) or if the whole column was empty (0).
Below is a table similar to what I’m working with. Idea is we have Items (standalone or part of a group) that will be packed in box(es). If a line is a group, the number of different items in a given group is indicated in column B (and the line of these items will always be following the group line). Range D4:G8 serves to enter quantity of item in each box. No quantity is entered for a group.
For each group, however, I want to calculate the total weight of all boxes containing items from that group. So, for each item that is part of that group (line), check in each box (column) if there is a quantity present (1) or not (0), and multiply that by the weight of the box.
In other words, I think I need a function like:
…where ColumnsAreNotEmpty() would return a 1D array with the values {1,1,1,0} in this particular example. However, is it possible to achieve this without writing a function? Can this be done just with SUMPRODUCT and/or the use of an array formula?
Note that, for usability purposes, I would like the table of quantities (D4:G8) to contain only user-entered data, no formula. It would be to easy otherwise… :P
Thanking you in advance for any hint, advice or answer,
FD
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]
[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD="align: right"]Box ID[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD="align: right"]Weight[/TD]
[TD]30[/TD]
[TD]25[/TD]
[TD]20[/TD]
[TD]20[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]GRP/ITEM[/TD]
[TD](nbItems)[/TD]
[TD]Total Qty[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]Total weight of boxes with items in group?[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]GRP1[/TD]
[TD="align: right"]2[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD="align: center"]75 (= weight of boxes 1+2+3)[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD="align: right"]ITEM1[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD="align: right"]ITEM2[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]ITEM3[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]ITEM4[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
</tbody>[/TABLE]
I feel this is possible, but I’m not familiar enough with Excel array formulas and pro uses of SUMPRODUCT function to find how to make it possible. I'm stuck and need your help.
Given a dynamic 2D range (result of an OFFSET function), I would like calculate a value for each column of that range, and pass that 1D array of values as an argument to the SUMPRODUCT function.
Specifically, each value of the 1D array would indicate if the corresponding column in the dynamic range had at least one non-empty cell (1) or if the whole column was empty (0).
Below is a table similar to what I’m working with. Idea is we have Items (standalone or part of a group) that will be packed in box(es). If a line is a group, the number of different items in a given group is indicated in column B (and the line of these items will always be following the group line). Range D4:G8 serves to enter quantity of item in each box. No quantity is entered for a group.
For each group, however, I want to calculate the total weight of all boxes containing items from that group. So, for each item that is part of that group (line), check in each box (column) if there is a quantity present (1) or not (0), and multiply that by the weight of the box.
In other words, I think I need a function like:
Code:
I4 = SUMPRODUCT( D2:G2; ColumnsAreNotEmpty( OFFSET(D4:G4;1;0;B4 )) )
…where ColumnsAreNotEmpty() would return a 1D array with the values {1,1,1,0} in this particular example. However, is it possible to achieve this without writing a function? Can this be done just with SUMPRODUCT and/or the use of an array formula?
Note that, for usability purposes, I would like the table of quantities (D4:G8) to contain only user-entered data, no formula. It would be to easy otherwise… :P
Thanking you in advance for any hint, advice or answer,
FD
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]
[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD="align: right"]Box ID[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD="align: right"]Weight[/TD]
[TD]30[/TD]
[TD]25[/TD]
[TD]20[/TD]
[TD]20[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]GRP/ITEM[/TD]
[TD](nbItems)[/TD]
[TD]Total Qty[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]Total weight of boxes with items in group?[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]GRP1[/TD]
[TD="align: right"]2[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD="align: center"]75 (= weight of boxes 1+2+3)[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD="align: right"]ITEM1[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD="align: right"]ITEM2[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]ITEM3[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]ITEM4[/TD]
[TD="align: center"]#N/A[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]
[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]
[/TD]
[TD="align: center"]#N/A[/TD]
[/TR]
</tbody>[/TABLE]