Cycles and iteration control in different threads.

  • Reproducible workflow examples (see the linked post for more detail)
  • Sample input and/or output data, if at all possible. If your data is business confidential, please consider creating a small mockup dataset to allow community members to recreate the problem

but tldr:
A) counting loop, filtering by index
B) column list loop
C) unpivoted joins
D) Matrix Multiplication Masks

plenty more options but given you dont provide example data nor a scope, no one can give you a proper feedback because some solutions are bad choices for large datasets.
and given you didnt provide what you created so far, no one knows what improvement to recommend either.