How do I use if statements to create a global text variable?

Total beginner here: I'm trying to create my first-ever global variable. In this instance, I want to use if statements to change li(admin) into abbreviations, e.g...

$if(li(admin)="Alabama","AL")$
$if(li(admin)="Alaska","AK")$

...and so on. I created a text global called "abbrev", pasted in the list of if functions, and added it to the formula for the text of the location info:

$li(loc)$, $gv(abbrev)$

...but nothing happened. I can see that the gv function is pulling the abbreviation in the editor, but it doesn't show up in the preview nor the widget. What am I doing wrong?