Forum Discussion
AhmadBakr
Helper IV
1 year agoHow SUMMARIZE works and does it create a row context?
I have this employee sample dataset, fact table is Employees: emp ID BU Days 1 1 0 1 1 30 1 1 60 2 1 0 2 1 30 3 1 0 3 1 30 3 1 60 3 1 90 ...
- 1 year ago
Praful_Potphode
Super User
1 year agoHi 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 T2Please give kudos or mark it as solution once confirmed.
Thanks and regards,
Praful