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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate Difference Between Global Average

Hello,

 

I am trying to calculate a difference between a customer's proportion of sales in product groups vs the global average proportion for that customer's product group. 

 

For example I have a transaction table which is like this

Customer IDInvoice IDCustomer GroupProduct Group...Line Sales
001001Group 1Stationary...10
001002Group 1IT...54
005003Group 2Stationary...5
..................

 

I then have a global table which summarizes the total sales by customer and product group like this

Customer GroupProduct GroupSales
Group 1Stationary10000
Group 1IT2000
Group 1Office Furniture500
Group 2Stationary5000
Group 2IT5000
Group 2Office Furniture1000

 

I would like to product a dynamic graphic which, when I select a particular customer it shows me a graph like this:

 

image.png

 

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous 

 

Refer to the following DAX:

Selected Customer =
CALCULATE (
    COUNT ( 'Table'[Customer ID] ),
    ALLSELECTED ( 'Table'[Customer ID] )
)
    / COUNTROWS ( ALLSELECTED ( 'Table' ) )
Global =
CALCULATE (
    SUM ( 'Table'[Line Sales] ),
    ALLEXCEPT ( 'Table', 'Table'[Product Group], 'Table'[Customer Group] )
)
    / CALCULATE (
        SUM ( 'Table'[Line Sales] ),
        ALLEXCEPT ( 'Table', 'Table'[Customer Group] )
    )

 

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Anonymous 

 

Refer to the following DAX:

Selected Customer =
CALCULATE (
    COUNT ( 'Table'[Customer ID] ),
    ALLSELECTED ( 'Table'[Customer ID] )
)
    / COUNTROWS ( ALLSELECTED ( 'Table' ) )
Global =
CALCULATE (
    SUM ( 'Table'[Line Sales] ),
    ALLEXCEPT ( 'Table', 'Table'[Product Group], 'Table'[Customer Group] )
)
    / CALCULATE (
        SUM ( 'Table'[Line Sales] ),
        ALLEXCEPT ( 'Table', 'Table'[Customer Group] )
    )

 

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
amitchandak
Super User
Super User

@Anonymous 

You can create a category Average and use

https://community.powerbi.com/t5/Desktop/Calculate-Average-per-category/td-p/362637

 

You have an option in Quick measure too

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.