Forum Discussion

POSPOS's avatar
POSPOS
Icon for Post Partisan rankPost Partisan
2 years ago
Solved

Incorrect average using DAX

Hi All, I have a requirement to show the avergae of data for different protocols. Please find sample date below:   Issue: When one protocol is selected, then the values for same statuses...
  • Greg_Deckler's avatar
    2 years ago

    POSPOS Try this:

    Measure = 
      VAR __Protocols = COUNTROWS(DISTINCT('Table'[Protocol]))
      VAR __Sum = SUM('Table'[No. of days])
      VAR __Result = DIVIDE(__Sum, __Protocols)
    RETURN
      __Result
  • Ashish_Mathur's avatar
    2 years ago

    Hi,

    Write these measures

    D = SUM('Table (2)'[No. of days])
    Measure = AVERAGEX(VALUES('Table (2)'[Protocol]),[D])

    Drag the second one to the visual.

    Hope this helps.