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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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