AVERAGE vs AVERAGEX DAX Function Difference with Example

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:
    1. VALUES('Patients'[Doctor Name]) creates a table of distinct doctors.
    2. For each doctor, CALCULATE(AVERAGE(...)) gets their average recovery score.
    3. 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:

DoctorPatientsAvg Recovery Score
Dr. A380
Dr. B260
Dr. C190
  • AVERAGEX Result: (80 + 60 + 90) / 3 = 76.67
  • AVERAGE 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.