Refactor measure interface into typed and untyped

The untyped interface more closely aligns with its current usage and
allows the database to deal with types.