I think you pretty much solved your own problem. Just use $iif.

$iif($blah,$blah,bleh)