Forum Discussion

MileBI's avatar
MileBI
New Member
2 years ago
Solved

AverageX function not calculating per row In PowerBI

New user here!
test = 
AVERAGEX('Weekly Report','Weekly Report'[Days In-Office/Travel]+'Weekly Report'[Holidays in selected period]+'Weekly Report'[Days with Time Away])
 
I am trying to get average of 3 columns by row.
My understanding was the x function(averagex, sumx, countx) were used to provided calculation by row and not for the whole column data.
Though this providing a total average instead of individual average
 



  • MileBI 

    if you want to sum the 3 columns and divide by 3 

    you just need to use the following : 

     

    ('Weekly Report'[Days In-Office/Travel]+'Weekly Report'[Holidays in selected period]+'Weekly Report'[Days with Time Away] ) / 3 

     

     

    if not , then please share how you want to average to be calculated. 

     

     

    if this helps kindly mark as an accepted solution as this wjll help others to find the answer easily. 

     

  • Hi MileBI 
    Averagex is an iterating function, so when you use it as a calculated column it iterates the calculation by column level.
    If you need just an average between  3 columns just use a simple :

    average = divide(
        ([a]+[b]+[c]),3)

    more details about how iteration functions work are here :
    https://www.youtube.com/watch?v=-3snD-VOqik

    it is about sumx, but all of those functions work with the same logic 
    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

4 Replies

  • Daniel29195's avatar
    Daniel29195
    Community Champion

    MileBI 

    if you want to sum the 3 columns and divide by 3 

    you just need to use the following : 

     

    ('Weekly Report'[Days In-Office/Travel]+'Weekly Report'[Holidays in selected period]+'Weekly Report'[Days with Time Away] ) / 3 

     

     

    if not , then please share how you want to average to be calculated. 

     

     

    if this helps kindly mark as an accepted solution as this wjll help others to find the answer easily. 

     

    • MileBI's avatar
      MileBI
      New Member

      Thanks, I guess I was trying to make it more complicated then is needs.
      This option works

  • Hi MileBI 
    Averagex is an iterating function, so when you use it as a calculated column it iterates the calculation by column level.
    If you need just an average between  3 columns just use a simple :

    average = divide(
        ([a]+[b]+[c]),3)

    more details about how iteration functions work are here :
    https://www.youtube.com/watch?v=-3snD-VOqik

    it is about sumx, but all of those functions work with the same logic 
    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

    • MileBI's avatar
      MileBI
      New Member

      Thanks, I guess I was trying to make it more complicated then is needs.
      This option works