I\'m having a fairly large dataset where I need to combine multiple entries into a single value. My dataset contains data on the combination of two datasets, each using thei
I want to give a shot to this question, after asking OP for some clarifications, because English is not my main language and I think I have misunderstood something.
So, what I did to simulate situation, made a new workbook with 2 sheets.
One sheet is named Landgebruik
and got a value in A2
and I did this:
The second sheet is named Raw data
. I hide some columns to use only columns C, O and S. In column S I input just values equal to 1. In column O I did randomly values equal to {20,21,22,23,40}
and in Column C I did randomly values which were A or B. And it looks like this (please, note I hide some columns):
And question would like to sum values in column S but only If column O is equal to 20 or 21 or 22 or 23 o 40 and column C is equal to Landgebruik!A2
(in my test, value in there is letter A
)
We can use an array formula to filter the data in column S and then, once filtered, sum values that meet requirements. In my test, the correct result would be 8, beause only 8 values in column S meet requirements of column C and O. In the image, the right rows are highlighted in yellow.
OP already did this, but wants to know if there is a shorter/elegant formula.
Shortest formula I found is like this:
=SUM(IF($O$2:$O$28={20;21;22;23;40};IF($C$2:$C$28=Landgebruik!$A$2;$S$2:$S$28)))
This is an array formula, so it must be inserted pressing CTRL+SHIFT+ENTER or it won't work!
HOW IT WORKS:
First IF
takes all values in column S and ignores all where equivalent in Column O are not 20 or 21 or 22 or 23 or 40. Second IF
takes that new array, and ignores all values where equivalent in column C are not equal to Landgebruik!$A$2
. Final array is sumed up by the function SUM
I've tried to explain the best I can. I hope you can adapt this to your needs.