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
Even though this has been done hundreds of times before, hey maybe microsoft switched up the formulas or something.
I am partial to the method Jerry and Me suggested as they are simple as hell and concise, but you pay a heavy performance cost.
Tom's formula looks ugly to me but was fastest by far, about 4x faster than my initial example. We were able to incorporate the {}s with Tom's formula, but to get it to work we had to wrap the sumifs function with a sum function. This slowed down the formula considerably but made it prettier.
z32a7ul had a great solution too. I really like the use of -- and learned how to use |s to search for a text and only that text. At first glance I thought that it would not work on a number such as 2323 but it does.
Mock up example was as follows:
A1:A5000 was filled with LandgeBruik,
B1:B5000 was filled with 40's
C1:5000 was filled with 1's.
The results:
=SUMPRODUCT((A1:A5000="LandgeBruik")*(B1:B5000={20,21,22,23,40})*C1:C5000)
19.186031 seconds elapsed | 59,818,073 ticks
{=SUM(IF(A1:A5000="Landgebruik",1,0)*IF(B1:B5000={20,21,22,23,40},1,0)*C1:C5000)}
26.124411 seconds elapsed | 81,450,506 ticks
{=SUM((A1:A5000=""Landgebruik"")*(B1:B5000={20,21,22,23,40})*C1:C5000)}
21.111835 seconds elapsed | 65,822,330 ticks
"=SUMIFS(C1:C5000,B1:B5000,"">=20"",B1:B5000,""<=23"",A1:A5000,""=Landgebruik"")+SUMIFS(C1:C5000,B1:B5000,""=40"",A1:A5000,""=Landgebruik"")"
6.732804 seconds elapsed | 20,991,490 ticks
"=SUM(SUMIFS(C1:C5000,A1:A5000,"Landgebruik",B1:B5000,{21,22,23,24,40}))"
16.954528 seconds elapsed | 52,860,709 ticks
"=SUMPRODUCT(--(A1:A5000=""Landgebruik""),--NOT(ISERROR(FIND(""|""&B1:B5000&""|"",""|20|21|22|23|40|""))),C1:C5000)"
11.822379 seconds elapsed | 36,859,729 ticks