AFAIK -
There is no way to create a loop within a expression. Expressions are basically a single line of logic. You can however 'chain' expressions and somewhat create a loop but Archicad expressions have nothing like a FOR or WHILE loop. Hopefully we'll get a script language in the future??
Expressions also can only address single objects. To sum areas, as in windows, use the interactive schedule filter to return the window areas of interest and then just use the 'sum' column feature.
Gerry
Windows 11 - Visual Studio 2022; ArchiCAD 27