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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AhmadBakr
Advocate II
Advocate II

How SUMMARIZE works and does it create a row context?

I have this employee sample dataset, fact table is Employees:

 

emp ID        BUDays
110
1130
1160
210
2130
310
3130
3160
3190
4210
4220
5210
5220
5230

 

I want to get average days per business unit (BU), but since each employee has repeated records, I want to use the record with maximum number of days to express working days of each employee. I used the below in DAX query view:

 

Note:

T1 is intermediate to group for max days.

T2 is the target, but returned wrong results: average over all T1, not average grouping over BU!

T3 and T4 returned correct results.

 

Why did T2 fail? Why it did not create [BU] row context and group on it like T1 did with [emp ID]

 

EVALUATE
VAR T1 =
SUMMARIZE(
    Employees,
    Employees[emp ID],
    Employees[BU],
    "MaxD", MAXEmployees[Days] )
)
VAR T2 =
SUMMARIZE(
    T1,
    Employees[BU],
    "AvD", AVERAGEXT1, [MaxD] )
)
VAR T3 =
ADDCOLUMNS(
    VALUESEmployees[BU] ),     // SUMMARIZE(Employees, Employees[BU]) also works here in place of VALUES()
    "AvD",
    AVERAGEX(
        FILTER(
            T1,
            Employees[BU] = EARLIEREmployees[BU] )
        ),
        [MaxD]
    )
)

VAR T4 =
GROUPBY(
    T1,
    Employees[BU],
    "AvD", AVERAGEXCURRENTGROUP(), [MaxD] )
)

RETURN T4
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

5 REPLIES 5
Praful_Potphode
Solution Supplier
Solution Supplier

Hi @AhmadBakr ,

 

AVERAGEX(T1, [MaxD]) is evaluated once for the entire T1 table — not per BU.Even though SUMMARIZE lists Employees[BU], it doesn’t automatically create row context for AVERAGEX to iterate per BU.So T2 ends up calculating the overall average of all MaxD values, and repeats that same value for every BU

VAR T1 =
SUMMARIZE(
Employees,
Employees[emp ID],
Employees[BU],
"MaxD", MAX(Employees[Days])
)

VAR T2 =
ADDCOLUMNS(
SUMMARIZE(T1, Employees[BU]),
"AvD",
CALCULATE(AVERAGEX(T1, [MaxD]))
)

RETURN T2

Please give kudos or mark it as solution once confirmed.

Thanks and regards,
Praful

In fact looks like SUMMARIZE operation is very complex. The article shared by @lbendlin above is very useful and reminded me of similar articles published by SQLBI on SUMMARIZE, and many videos on the toutube channel as well.

lbendlin
Super User
Super User

Buckle up, this will be a wild ride.

 

All the secrets of SUMMARIZE - SQLBI

I also found this, as a legit better option: SUMMARIZECOLUMNS

 

SQLBI again.

 

https://youtu.be/yf0T6H1gP7I?si=oAvAGaOKE3j_jYl_

Thank you very much. This is quite deep and thourough

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.