Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
chahineatallah
Helper III
Helper III

Nested Iterators

hello, am having hard time understanding nested iterators

 

I created one small table with quantities but still am not understanding why am having different results

1. I created regular quantity calculation which is SUMX(Table1,Table1[quantity])

2. I created nested quantity calculation using quantity measure = SUMX(table1,[quantity sumx]) which is sumx & then my previously created measure quantitysumx

3. I created nested quantity calculation using SUMX(Table1,SUMX(Table1,Table1[quantity]))

so my question why items 2 & 3 giving different results although both have nested sumx, to my knowledge sumx should iterate row by row, so when i have nested , then for example if i take product a first sumx should be 10+3, then second sumx should be again 13+13 as it is row by row , but when am using measure instead of sumx , its giving different result

i attached below results 

quantity measure.pngquantity sumx.pngquantity sumx1.png

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @chahineatallah 
The reason is context transition. By default all measures are wrapped with CALCULATE forcing context transition. In your case I can tell that products A and B each has two rows while product C has only one row. In the case on nested SUMX and two rows per product the result will be doubled as for each row the inner SUMX will produce the sum of the two rows visible in the current filter context. While when referring to a measure or when wrapping the inner SUMX with CALCULATE then each row or the outer SUMX will be transformed into a filter context that will bring the rows of iteration of the inner SUMX down to only one row. 
This is why when there is only one row per product the result of the two measures is the same.

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @chahineatallah 
The reason is context transition. By default all measures are wrapped with CALCULATE forcing context transition. In your case I can tell that products A and B each has two rows while product C has only one row. In the case on nested SUMX and two rows per product the result will be doubled as for each row the inner SUMX will produce the sum of the two rows visible in the current filter context. While when referring to a measure or when wrapping the inner SUMX with CALCULATE then each row or the outer SUMX will be transformed into a filter context that will bring the rows of iteration of the inner SUMX down to only one row. 
This is why when there is only one row per product the result of the two measures is the same.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.