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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
qqqube
New Member

about evaluation context

there is an example in Microsoft training modules 2-aggregation-iterator-functions . and in the higher grain summarization part, it gives a formula:

Revenue Avg Order =
AVERAGEX(
    VALUES('Sales Order'[Sales Order]),
    [Revenue]
)

where [Revenue] is:

Revenue =
SUMX(
    Sales,
    Sales[Order Quantity] * Sales[Unit Price] * (1 - Sales[Unit Price Discount Pct])
)

lets put them together:

Revenue Avg Order =
AVERAGEX(
    VALUES('Sales Order'[Sales Order]),
    SUMX(
      Sales,
      Sales[Order Quantity] * Sales[Unit Price] * (1 - Sales[Unit Price Discount Pct])
    )
)

my question is:

     is the formula above the same as this one? why?

(I test these two formulas and find them return the same result in my data model. )

Revenue Avg Order2 =
AVERAGEX (
    VALUES('Sales Order'[Sales Order]),
    SUMX (
        FILTER(Sales, Sales[Sales Order] = EARLIER('Sales Order'[Sales Order])),
        Sales[Order Quantity] * Sales[Unit Price] * (1 - Sales[Unit Price Discount Pct])
    )
)

 

1 ACCEPTED SOLUTION
qqqube
New Member

chatgpt gives an answer as follows:

Execute SUMX

  • For each Sales Order, AVERAGEX passes the current Sales Order as the row context and evaluates the SUMX function.
  • SUMX(Sales, ...) iterates over the Sales table. However, because DAX applies the current row context automatically, the SUMX will only process rows in the Sales table that match the current Sales Order.
  • This is due to DAX’s context propagation, where the outer row context (in this case, the current Sales Order) is passed into the inner calculation, so SUMX operates only on rows that match the Sales Order.

View solution in original post

2 REPLIES 2
dharmendars007
Super User
Super User

Hello @qqqube , 

 

Yes, Both formulas will give the same result but DAX automatically handles the filter context efficiently in Formula 1..

 

If you find this helpful , please mark it as solution and Your Kudos are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

qqqube
New Member

chatgpt gives an answer as follows:

Execute SUMX

  • For each Sales Order, AVERAGEX passes the current Sales Order as the row context and evaluates the SUMX function.
  • SUMX(Sales, ...) iterates over the Sales table. However, because DAX applies the current row context automatically, the SUMX will only process rows in the Sales table that match the current Sales Order.
  • This is due to DAX’s context propagation, where the outer row context (in this case, the current Sales Order) is passed into the inner calculation, so SUMX operates only on rows that match the Sales Order.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.