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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
taimaizumi
Helper I
Helper I

How iterator function deal with the first argument

Hi, all.

 

Please help me to understand how to use iterator function.

 

Iterator functions such as sumx need 'table' as first argument.

taimaizumi_0-1657581403916.png

 

But, I don't understand well that 'table' will be dealed with by function.

My understanding is that 'table' passed to function is used for deciding the scope of iteration

For example, I'll take below schema.

 

taimaizumi_1-1657582982967.png

taimaizumi_2-1657583010631.png

 

Based on this, I tested some measure using sumx

 

  1. sumx1 = SUMX('Fact_001_Qty','Fact_001_Qty'[Qty])
    ->This worked well, but I don't understand why I can get this result. Because due to first argument, row context is generated by whole 'Fact_001_Qty', so sum is done by not category but 'Category' , 'Product' and 'Qty' (= row by row)taimaizumi_3-1657583118954.png

     

  2. sumx2 = SUMX(VALUES('Fact_001_Qty'[Category]),'Fact_001_Qty'[Qty])
    ->The error occured. My understanding is that 'VALUES('Fact_001_Qty'[Category]' makes row context by Category and next sum is done by Category. 

    taimaizumi_4-1657583419071.png

 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

A simple SUM() function should work there.  You do not need a SUMX() function at all.  If you realy want to use the SUMX() function, then try these measures

Total = SUM('Fact_001_Qty'[Qty])

sumx2 = SUMX(VALUES('Fact_001_Qty'[Product]),[Total])

To your visual drag Category and sumx2 measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
taimaizumi
Helper I
Helper I

@Ashish_Mathur 

I apriciate your answer.


I can get expected result as following your advise.

 

taimaizumi_0-1657599381768.png

Could I ask additional question about it?

 

Why do I get that result by just using SUM function?

I think that context transition may occur, is it corret?

 

I mean that 'VALUES('Fact_001_Qty'[Product])' generate row text by non-repeated Product at first

and then context transiton occurs into filter context , finally SUM is calculated by Product.

 

I really appreciate if you could correct me if I'm wrong.

 

Best regards

Ashish_Mathur
Super User
Super User

Hi,

A simple SUM() function should work there.  You do not need a SUMX() function at all.  If you realy want to use the SUMX() function, then try these measures

Total = SUM('Fact_001_Qty'[Qty])

sumx2 = SUMX(VALUES('Fact_001_Qty'[Product]),[Total])

To your visual drag Category and sumx2 measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.