Here is the the difference between AVERAGE
vs AVERAGEX
with a realistic example using your Hospital Patient Treatment Dataset (which includes patients, doctors, recovery scores, treatment cost, etc.).
❓ Question:
What is the average of the average recovery score per doctor?
🔍 Why This Matters:
AVERAGE([Recovery Score])
will give you the average across all patients.AVERAGEX(...)
allows you to first group by doctor, get each doctor’s average score, and then take the average of those.
Here is the dataset snapshot

✅ DAX Using AVERAGEX (Correct for per-group logic):
AvgOfAvgRecoveryByDoctor =
AVERAGEX(
VALUES('Patients'[Doctor Name]),
CALCULATE(AVERAGE('Patients'[Recovery Score]))
)
- Explanation:
VALUES('Patients'[Doctor Name])
creates a table of distinct doctors.- For each doctor,
CALCULATE(AVERAGE(...))
gets their average recovery score. AVERAGEX
then averages those doctor-wise averages.
🔁 Compare With Simple AVERAGE (Flat):
OverallAvgRecovery = AVERAGE('Patients'[Recovery Score])
- This gives the overall average, ignoring doctor grouping.
📊 Example:
Doctor | Patients | Avg Recovery Score |
---|---|---|
Dr. A | 3 | 80 |
Dr. B | 2 | 60 |
Dr. C | 1 | 90 |
AVERAGEX
Result: (80 + 60 + 90) / 3 = 76.67AVERAGE
Result: (All 6 recovery scores total) / 6 = something different, like 76.17
✅ Conclusion:
Use AVERAGEX
when you want to average aggregated results across groups (like doctors, departments, or treatment types).
Use AVERAGE
when you want the simple row-level average.