Forum Discussion

LickNewin's avatar
LickNewin
Regular Visitor
2 years ago
Solved

Dividing the Subtotal without changing Values in Matrix

I'm trying to create a Power BI Measure that calculates an Average based on the amount of years (We use a relative date for the past 5 years, so the average should just be the sum of the row, divided by 5). I've tried to write the below Measure which adds the Average as a column but it's not calculating it correctly.

 

 

 

This is what it should look like - notice that the Average should be the total of each Age Bracket, divided by 5 for the amount of years.

As an example, for the '18-25' Age Bracket, the Sum total is 11, and when divided by 5, should give an average of 2.20 over 5 years.

Age Bracket20202021202220232024Average
Junior001000.20
18-25223402.20
26-30223001.40
31-35002301.00
36-40001200.60
41-45011000.40
46-50012501.60
51-55012000.60
56-60113101.20
61-65034001.40
66-70162502.80
71-75254403.00
76-802511504.60
81-850651104.40
86-90236603.40
91-95001200.60
96-99010000.20
100+100000.20

 

10 Replies

  • LickNewin's avatar
    LickNewin
    Regular Visitor

    It's a little hard to see, but the current measure that isn't working is:

     

    Measure =
    AVERAGEX(VALUES(JoinedData1[Resignation Year]), CALCULATE(COUNT(JoinedData1[Member Number])))
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi LickNewin 

     

    Please try the following DAX:

    Average Over 5 Years = 
    SUMX(
        VALUES('JoinedDate1'[Age Bracket]), 
        CALCULATE(SUM('JoinedDate1'[Member Number])) / 5
    )

     

     

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • LickNewin's avatar
      LickNewin
      Regular Visitor

      Hey Jayleny, 

      Unfortunately this doesn't work as the Column 'Age Bracket' is a String, not a number.

      Some of the age brackets are "Junior" or "100+" so include characters other than numbers.

       

      Please see the example PBIX attached here:

      Working Average Function.pbix