Forum Discussion
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.
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.
Based on this, I tested some measure using sumx
- 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) - 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.
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.
2 Replies
- Ashish_MathurSuper 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.
- AnonymousNot applicable
I apriciate your answer.
I can get expected result as following your advise.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