I have the following data in a google spread sheet. ColumnA         ColumnB=======================Bus             205Train           10Train           10Fruit           10I want to sum all ColumnB where ColumnA is equal to either Bus or Train. I know that I can sum all content of B based on single value of A like below=(SUMIF(A:A, Bus, B:B))But I want to sum if column A contains any of the values that I specify. How can I do that?
Sum a column if another column contains any of the values
google spreadsheets
Short answer=ArrayFormula(sum(sumif(A:A,{Bus;Train},B:B)))ExplanationA:A is the column containing the categories.{Bus;Train} is a 1x2 array. It could be replaced by a range 1xn arrange containing the categories to be included in the sum.B:B is the column containing the values to be summed.sumif returns of the sum of values corresponding to each specified categorysum returns the sum of the returned array by sumifArrayFormula : Enables the display of values returned from an array formula into  multiple rows and/or columns and the use of non-array functions with  arrays.ReferenceUsing arrays in Google Sheets - Google Docs editors HelpARRAYFORMULA - Google Docs editors Help