MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Iterators (SUMX, AVERAGEX)0%
Study MaterialsCheatsheet
Power BI for IntermediateProgress 0%
1.1Quick recap of Import, Modeling, DAX1.2Project requirements for Intermediate Level
2.1Time Intelligence Functions2.2Iterators (SUMX, AVERAGEX)2.3CALCULATE and FILTER Functions
HomeTutorialsPower BI for IntermediateIterators (SUMX, AVERAGEX)
CALCULATE and FILTER Functions

Iterators (SUMX, AVERAGEX)

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

DAX Iterators: Row-by-Row Evaluation with SUMX, AVERAGEX & RANKX

Standard aggregation functions (SUM, AVERAGE, MIN, MAX) take a single column as input and aggregate all visible values in that column under the current filter context. However, real-world business formulas frequently require calculating values row-by-row before aggregating—this is the domain of DAX Iterators (commonly known as the "X-Functions").


1. Aggregators vs. Iterators

FeatureStandard Aggregators (SUM, AVERAGE)Iterators (SUMX, AVERAGEX, MAXX, MINX)
SyntaxSUM(Table[Column])SUMX(Table, RowExpression)
InputA single column referenceA table (or table expression) AND a scalar row calculation
Evaluation MechanismOperates strictly across the pre-existing columnIterates row-by-row, computes the expression in Row Context, then aggregates
Memory EfficiencyHigh (native columnar scan)High (avoids creating permanent calculated columns in memory)
1The SUMX Execution Pipeline:
2Table: Fact_OrderItems (Rows 1 to N)
3 [Row 1]: Qty (2) * UnitPrice ($50) * (1 - Discount 0.10) = $90
4 [Row 2]: Qty (1) * UnitPrice ($120) * (1 - Discount 0.00) = $120
5 [Row 3]: Qty (5) * UnitPrice ($10) * (1 - Discount 0.20) = $40
6 |
7 +---> VertiPaq sums the results: $90 + $120 + $40 = $250!

2. Implementing SUMX: Dynamic Revenue Calculation

Instead of polluting your data model with a calculated column for line total, compute it dynamically:

1-- Total Net Sales using SUMX
2Total Net Sales =
3SUMX(
4 Fact_OrderItems,
5 Fact_OrderItems[Quantity] * Fact_OrderItems[UnitPrice] * (1 - Fact_OrderItems[DiscountRate])
6)

Filtering Inside an Iterator

Because the first argument of an iterator is any valid Table Expression, you can combine iterators with FILTER:

1-- High-Value Order Sales (Orders with Sales > $1,000)
2High Value Sales =
3SUMX(
4 FILTER(
5 Fact_OrderItems,
6 Fact_OrderItems[UnitPrice] > 1000
7 ),
8 Fact_OrderItems[Quantity] * Fact_OrderItems[UnitPrice]
9)

3. Dynamic Ranking with RANKX

RANKX evaluates a table and ranks each row dynamically according to a measure:

1-- Rank Products by Sales
2Product Sales Rank =
3IF(
4 ISBLANK([Total Sales]),
5 BLANK(),
6 RANKX(
7 ALL(Dim_Product[ProductName]),
8 [Total Sales],
9 ,
10 DESC,
11 Dense
12 )
13)

RANKX Parameter Breakdown

  1. 1
    Table (ALL(Dim_Product[ProductName])): The list of all items to be ranked. Using ALL removes outer row filters so each product is compared against all products.
  2. 2
    Expression ([Total Sales]): The metric used for ranking.
  3. 3
    Value (Omitted): Evaluates the expression for the current item.
  4. 4
    Order (DESC): Highest sales receives Rank 1.
  5. 5
    Ties (Dense): Tied ranks do not skip numbers (e.g., 1, 2, 2, 3 instead of 1, 2, 2, 4).

4. Performance Considerations for Iterators

  • Iterators introduce Row Context. When nesting iterators inside other iterators (e.g., SUMX(..., AVERAGEX(...))), the VertiPaq engine must perform quadratic loop iterations, which can degrade report speed on datasets with millions of rows.
  • Always filter tables as early as possible using the smallest table expression in the first parameter.

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
What is the fundamental difference between SUM(Table[Sales]) and SUMX(Table, Expression)?
Question 2
In the formula SUMX(Fact_Sales, Fact_Sales[Qty] * Fact_Sales[Price]), what context is created by SUMX to evaluate Qty * Price?
Question 3
Why is using ALL(Dim_Product[ProductName]) inside RANKX essential when ranking products in a table visual?
Question 4
What tie-breaking method in RANKX assigns consecutive ranks (e.g., 1, 2, 2, 3) without skipping rank positions?
Question 5
Why is replacing multiple Calculated Columns with a single SUMX measure considered a Power BI performance best practice?

Next Lesson

CALCULATE and FILTER Functions

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Time Intelligence FunctionsCALCULATE and FILTER Functions

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

12-Month Data Analysis Mastery Program

Master Full-Stack Data Analytics (Excel, SQL, Python, Power BI & Tableau)

Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext