indeed missing function to work with alternative dimensions/measures.
may i suggest use the "qs variable" extension:
create a variable containing your dimension name, and use that variable as dimension and as parameter in your reference line
vDimension = 'CategoryName' or 'Country' (toggle with a button in the extension)
ref line : if($(vDimension)='Country',..., ... )