Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jayjay0306
Helper III
Helper III

AVERAGEX - calculated vertically instead of horizontal

hello Experts,

I hope you can help me with a challange:

Very "boiled down", I have four tables in Power BI, "customer" (columns: customer, customer chain), "Activity" (column: "number of contacts made to the customer"), "Organisation" (column: "Sales person").

I have a "matrix"-visual showing the average number of contacts per customer on "Chain"-level for each Sales person:

 

pic1.png

 

now, If I want to  calculate the average of chains for each sales person, I have made this measure:

Average contact per Chain= 
VAR ChainAverage = 
    AVERAGEX( 
       'Activity', 
       'activity'[index] 
   ) 
RETURN 
    AVERAGEX( 
        VALUES('Customer'[Customer Chain]), 
           ChainAverage 
   )

which, in essense, works. 

 

pic2.png

However, my problem is that the  "Average total" is not correct (if I manually calculate the average shown, I get the averages shown in red). I expect the reason for this is that power bi calculates on the row in context. I.e. it calculates the "Average total" horizontal. What I need, is to "force" the measure to calculate the average vertically.

 

Do anyone know how to do this?

 

thanks. All ideas are much appreciated.

 

Br,

Jayjay0306

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Your second AVERAGEX isn't doing anything since ChainAverage is a constant value once it's defined (it's the same for each row in the customer chain iterator).

 

I think you might want something more like this:

AVERAGEX (
    SUMMARIZE (
        Activity,
        Customer[Customer Chain],
        "@ChainAvg", AVERAGE ( activity[index] )
    ),
    [@ChainAvg]
)

(This assumes you have a one-to-many relationship from Customer to Activity.)

View solution in original post

3 REPLIES 3
jayjay0306
Helper III
Helper III

Thanks AlexisOlson, it is exactly what I want.

bloody brilliant 🙂

br,

Jayjay0306

Anonymous
Not applicable

Hi @jayjay0306 ,

I create a table as you mentioned.

vyilongmsft_0-1723612874302.png

Then I put it into the matrix visual.

vyilongmsft_1-1723613098121.png

If you want the vertical average column you are talking about, I think you can just make the change.

vyilongmsft_2-1723613282052.png

vyilongmsft_3-1723613402107.png

 

 

 

Best Regards

Yilong Zhou

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

AlexisOlson
Super User
Super User

Your second AVERAGEX isn't doing anything since ChainAverage is a constant value once it's defined (it's the same for each row in the customer chain iterator).

 

I think you might want something more like this:

AVERAGEX (
    SUMMARIZE (
        Activity,
        Customer[Customer Chain],
        "@ChainAvg", AVERAGE ( activity[index] )
    ),
    [@ChainAvg]
)

(This assumes you have a one-to-many relationship from Customer to Activity.)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.