Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extracting Sum of Various Columns based on value in other Columns in a repetitive array of Data

I need to find the sum of all matching items in the following data for which sumif() is going to be very lengthy and need a shorter way of doing it

The data structure is as follows:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here there are 20 items and hence a set of 4 columns repeats for every item.

Now, I want to get the total of items example
Item CA30 Total Item Qty = 10
Item CA10 Total Item Qty = 200

The new table should look like: (please ignore #N/A)

enter image description here

Link to sample sheet

>Solution :

Here’s a possible solution:

=LET(data,REDUCE(TOCOL(,1),SEQUENCE(20,1,1,5),
             LAMBDA(a,i,VSTACK(a,CHOOSECOLS(Data!E2:CZ,SEQUENCE(2,1,i,3))))),
     MAP(B2:B37,LAMBDA(code,SUMPRODUCT(INDEX(data,,1)=code,INDEX(data,,2)))))

enter image description here

The first part of the formula is arranging the data in a usable format then we are performing a simple conditional sum using the SUMPRODUCT function.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading