Looping is not available in Analytics however based on the data set using joins and appropriate operators you might achieve the same result that you are looking for.
We’d need to see a sample data set to better help you formulate an exact query.
-Dan