I have a column of cells that will line up with a header row for a time period (period 1, period 2, period 3, etc.) There is a 1 or 0 flag next to it if I want to use this period in my sum formula. 

I also have locations listed on my left column. 

How can create a sum formula to give me all amounts for a specific location if the period is flagged as 1 in the column next to it? I am assuming it will be some sort of sumif array, but I have not been successful is writing the formula.