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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Catman
Frequent Visitor

Calculating Weighted Average

I would like to calculate the weighted average value for each customer like below:

I need to calculate the Total Amount by customer and the weight %, then I can multiply by the Payment Days to obtain the weighted average.

Working      
CustomerInvoiceTotal Amount by CustomerAmount/TotalAmountPaymentdaysAverage Payment Days by Customer
A10001900,000.0010.2054%91,848909
A10002900,000.0037.5477%337,9294517
A10003900,000.004.9367%44,430904
A10004900,000.0039.5216%355,6954518
A10005900,000.007.7886%70,097907
    900,000 55

 

In the summary should be shown:

CustomerAverage Payment DaysTotal Amount
A55900,000

 

Any help is appreciated, thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Catman ,
Thank you for sharing the update!
It might happening because the total amount by customer is being calculated at the invoice level instead of staying fixed for the customer. This happens when the visual includes invoice-level detail, and the measure does not ignore that context. To get the right weight % and average payment days, the total amount should remain the same across all invoices for a customer. Also, since your Customer and Invoice tables are separate, just make sure there is a proper relationship between them.
Hope this helps.
Thank you.

View solution in original post

14 REPLIES 14
Anonymous
Not applicable

Hi @Catman ,
I hope the suggested solution worked for you. If your issue is resolved, kindly accept the helpful post as a solution — it helps the community identify helpful answers more easily.If still facing issues, feel free to reachout!
Thank you.

Regards,
Pallavi G.

Anonymous
Not applicable

Hi @Catman ,
Thank you community members for the helpful insights!
Following up to check whether you got a chance to review the suggestion given.If it helps,consider accepting the helpful answer as solution,it will be helpful for other members of the community who have similar problems as yours to solve it faster.
For precise help,could you please sample data and expected output.Glad to help.

Thank you.

Regards,
Pallavi.

Ashish_Mathur
Super User
Super User

Hi,

Which of those columns in Table1 are input columns?  HOw did you calculate the last column in Table1?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

could you pls provide some sample data?





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

Proud to be a Super User!




Hi, how can I upload an excel in this post? I have the calculation data in excel or do I need to open a new post? Sorry I am quite new to this fabric community. Thanks.

you can upload to onedrive then share the onedrive link in the reply. 





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

Proud to be a Super User!




Anonymous
Not applicable

Hi @Catman,
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Thank you.

Hopefully this is a bit easier to understand.

 

CustomerInvoiceTotal Amount by CustomerAmount/TotalAmountPaymentdaysAverage Payment Days by Customer
InputInputCalculated - sum Amount for CustomerCalculatedInputInput

Calculated 

% * Paymentdays

A10001900,000.0010.2054%91,848909
A10002900,000.0037.5477%337,9294517
A10003900,000.004.9367%44,430904
A10004900,000.0039.5216%355,6954518
A10005900,000.007.7886%70,097907
    900,000 55

Hi,

PBI file attached.

Ashish_Mathur_0-1752018402377.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @Catman ,
I have reviewed your values and performed the weighted average and total amount calculations using DAX .I got the below ouput:

vpagayammsft_0-1751960062569.png

The Weighted Average Payment Days is correctly calculated using the formula: SUMX at the Invoice level, where each Payment Days value is multiplied by the weight of that invoice (Amount divided by the Total Amount by Customer). This results in a weighted average of 55.00, which matches your expectation.
Regarding the Total Amount, the output is 899,999, not 900,000, because when we sum the actual Amount values you provided it is 899,999.Power BI result is accurate based on your data.

Please let us know if you require further help.Glad to help.

Thank you.

Hi, I have tried using the excel file from both solution to calculate the weight % but I keep having the same problem with the Total Amount by Customer. It just shows the individual Amount when I added the InvoiceID instead of aggregating the total.  

 

So this is what I keep getting as a result:

CustomerInvoiceAmountTotal Amount by CustomerPaymentdaysAmount/TotalAverage Payment Days by Customer
A1000191,84891,84890100%90
A10002337,930337,93045100%45
A1000344,43044,43090100%90
A10004355,695355,69545100%45
A1000570,09770,09790100%90
      360

 

The customer and invoice are 2 separate tables but this shouldn't have any impact, right?

And I can only create measure in the report, and not directly creating the new measures in the data table. 

 

Anonymous
Not applicable

Hi @Catman ,
Thank you for sharing the update!
It might happening because the total amount by customer is being calculated at the invoice level instead of staying fixed for the customer. This happens when the visual includes invoice-level detail, and the measure does not ignore that context. To get the right weight % and average payment days, the total amount should remain the same across all invoices for a customer. Also, since your Customer and Invoice tables are separate, just make sure there is a proper relationship between them.
Hope this helps.
Thank you.

bhanu_gautam
Super User
Super User

@Catman 

Create a new measure for Total Amount by Customer:

TotalAmountByCustomer = CALCULATE(SUM('Table'[Amount]), ALLEXCEPT('Table', 'Table'[Customer]))

 

Create a new column for Amount/Total:

AmountTotalPercentage = 'Table'[Amount] / 'Table'[TotalAmountByCustomer]

 

Create a new column for Weighted Payment Days:

WeightedPaymentDays = 'Table'[AmountTotalPercentage] * 'Table'[Paymentdays]

 

Create a new measure for Average Payment Days by Customer:

AveragePaymentDaysByCustomer = SUMX('Table', 'Table'[WeightedPaymentDays])

 

Create a summary table to display the results:
Add a table visual to your report.
Add the Customer column.
Add the AveragePaymentDaysByCustomer measure.
Add the TotalAmountByCustomer measure.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi,

By new column, is it the same as creating a new measure?

I can't seem to get the percentage to work. In the working table, the Total Amount shows only the individual amount when I include each invoice and payment Days value. Or does it only work in the summary?

 

I get the following result, I would expect the Total Amount to be 900,000

CustomerInvoiceAmountTotal AmountPaymentdaysAmount/Total
A

10001

91,848

91,848

90100%
A10002337,930337,93045100%
A

10003

44,43044,43090100%
A10004355,695355,69545100%
A1000570,09770,09790100%

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors