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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

wrong averaged weight

I am trying to get a weighted average (as a total), that is, for each customer, :

 

sum(value * size)     /  sum(size)

 

 

Tthe value is just a measure that is (SumPerCustomer / Max_PerCustomer)

 

...If a customer has (3 , 1,7 ) the measure shall be 11 / 7

 

 

I get the desired result for the value but not for the averaged weight:

 

VAR Max_PerCustomer =

MAXX(

    FILTER(

    SUMMARIZE(

        Revenue

        ,'Customer'[Customer]

        ,'Center'[Center]

    )

    , SUM(Revenue[Revenue]) > 0

)

    , SUM(Revenue[Revenue])

)

 

VAR SumPerCustomer =

CALCULATE(

    SUM(Revenue[Revenue])

    , FILTER(

    SUMMARIZE(

        Revenue

        ,'Customer'[Customer]

        ,'Center'[Center]

    )

    , SUM(Revenue[Revenue]) > 0

)

)



RETURN

 

SWITCH(

    TRUE()

    ,ISINSCOPE('Customer’[Customer]) , DIVIDE(SumPerCustomer, Max_PerCustomer)

    ,DIVIDE ( SUMX('Customer’,    DIVIDE(SumPerCustomer, Max_PerCustomer) * SumPerCustomer),  SUMX('Customer’, SumPerCustomer),0)

)

 

 

Any help is appreciated, I can't figure why it does the wrong calculation

4 REPLIES 4
ryan_mayu
Super User
Super User

@Anonymous 

could you pls provide the sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , try to add values and check

 

measure =
var _sel = selectedvalue(Param[Param])
var _cnt =distinctcount(Geography[locations])
var _1= CALCULATE([Sales],TOPN(_sel,all(Geography[locations]),[Sales],DESC),VALUES(Geography[locations]))
var _2= CALCULATE([Sales],TOPN(_cnt,all(Geography[locations]),[Sales],asc),VALUES(Geography[locations]))
return
if(_sel =0 || not(isfiltered(Param[Param])) , _2, _1)


calculate(
SWITCH(

TRUE()

,ISINSCOPE('Customer'[Customer]) , DIVIDE(SumPerCustomer, Max_PerCustomer)

,DIVIDE ( SUMX('Customer', DIVIDE(SumPerCustomer, Max_PerCustomer) * SumPerCustomer), SUMX('Customer', SumPerCustomer),0)

), values('Customer'[Customer]))

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
Anonymous
Not applicable

I can' quiet follow , what do you mean?

@Anonymous , values is group data at a level

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.