Google Sheets – How to Tie an Enum to Numeric Values

formulasgoogle sheetsgoogle-sheets-arrayformula

I created a list of items Data Validation in a sheet corresponding to time-frequency:

weekly,monthly,annually

I want to multiply values in a numeric column with the corresponding weekly values to get a normalized annual cost so weekly would be 52x, monthly 12x.

It's just three columns: one numerical, one with drop down of 3 possible text values (weekly, etc) and a final numerical (annual total). If I choose weekly from the drop down, I want the value in the first column to be multiplied by 52 and the result stored in the 3rd total column.

How do I accomplish this in Google Sheets?

Best Answer

=ARRAYFORMULA(IF(B1:B="weekly";   A1:A*52;
              IF(B1:B="monthly";  A1:A*12;
              IF(B1:B="annually"; A1:A*1; ))))

enter image description here