Caches case-when statement for better performance 

It improves performance about 5%.
Do you like this approach? Please merge this if you like it.