Improving repetitive use of IFs in Excel formula -


is there more efficient approach formula?

=if(a1="texas",1,)&if(a1="washington",2,)&if(a1="kansas",3,)&if(a1="california",3,) 

simple question, i'm sure there better way 1 i've got

you use table in worksheet , use vlookup,

enter image description here

or in 1 formula like

=lookup(a1,{"california","kansas","texas","washington"},{3,3,1,2}) 

the first array must sorted ascending.

edit: can catch errors wrapping statement ifna() this:

=ifna(lookup(a1,{"california","kansas","texas","washington"},{3,3,1,2}),"not found") 

"shorter" or "more efficient" depends on situation. lookup table shortest , it's quick add new states scenario.

the lookup formula fine if states , values not expected change.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -