This would have been a straightforward task if Y was pre-defined and we could hard-code that in the formula. Then it would’ve been something like
Items.Filter(CurrentValue.Class = Y1).WithName(X1s,
Items.Filter(CurrentValue.Class = Y2).WithName(X2s,
Items.Filter(CurrentValue.Class = Y3).WithName(X3s,
X1s.FormulaMap(CurrentValue.WithName(X1,
X2s.FormulaMap(CurrentValue.WithName(X2,
X3s.FormulaMap(CurrentValue.WithName(X3,
List(X1, X2, X3)
))))))
)))
But since we’re going to deal with the arbitrary number of Ys, we need to find a different way. And that would be counting in circles with integer division and modulo operations, in a similar way like I once did here:
I can take a go at this problem in some 30 minutes