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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
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.