Do you know about Dimensionality() ? If you have QV 11 you must have this function
This function returns the number of the dimensionality you are in that moment and you can use functions with that, for example, max(Dimensionality()) and I supose you could use Dimensionality()+1 and things like that.