# Doubt Understanding Iterators

When we’re talking about iterating function ,

Question : Is that evaluated per row and kept in memory for only rows related to each cell in filter context?

For example

When we try to see Total Sales product wise but for channel = “Export”, we see below figure using SUMX
Product 7 -->3973662.80

So does mean filter propagation results us first the set of rows related to product = product 7 in sales table & than for each row conditions are applied to filter channel & adding each row to memory that satisfy this filter.
And once rows for Product 7 are collected into memory sumx perform aggregation on top of same.

Thanks,
Harry

Hi Harry,

I don’t quite clearly understand the question.

I like to think of iterators of going row by row on a table & performing it’s operation & stacking this up. In your case, summing up. Now how the result gets displayed depends a lot on the context you have in place.

In your example, I assume you refer to a row context (?) of product 7 (bear in mind you could also have filter context for product 7 as well!). In any case, the measure is already saved in memory - sales figure for product 7 is applied only after depending on if it’s defined on context as row or filter.

Hope I understood your question well enough to respond. If not, provide visual example to help me understand better.

Regards,
Bare

Filtering happens first and then the math takes place.

1 Like

Hi @Bare
Sorry for such confusing post and really appreciate for your input.
But to put in simple words .

When ever we are applying iterator , its first selecting data for all filter context and then applying condition written in iterator functions for those selected rows.

Its not like the other way around, i.e. select rows for condition written in iterator and then applying filter context.

Thanks,
Harry

Check out this tutorial here. I really dive into this deeply

Also there’s many examples to run through here below also

https://blog.enterprisedna.co/tag/iterating-functions/

Iterating function allow you to iterate through a table (virtual or physical) and run logic at every single row. Once logic is completed at every single row, then the final calculation is completed (i. SUMX, AVERAGEX etc)

Sam