I think that the 'for loop' calculation is not available for use in the edit expression box. However you can use set analysis expressions.
If your calculations are complex, it is advisabe to do them in the load script. If the calculations depend on the selections made by the user, you need to become creative. You can group your calculations into two parts, user-input-independent and user-input-dependent. In the user-input-independent group, you should try to calculate either the final results to display/use in the charts/chart-expressions or intermediate results for use by the user-input-dependent group to arrive at the final numbers for use in the charts/chart-expressions.
Hope this helps.
Right, you don't do a for loop in an expression. You're thinking procedurally, which is not how the expressions operate. But your answer MIGHT be trivial. If, for instance, you had a chart with customer as the dimension, and you wanted to execute this for loop in every cell in the chart:
total quantity = 0
for each order that the customer on this row has placed
add ordered quantity to total quantity
display total quantity
That's just this expression:
That's probably not what you're asking, but you're going to have to be a lot more explicit if you want anyone answering your question to be more explicit.