Refactor cube query when inherited from xtab