Forum Discussion
Calculating Weighted Average
- Anonymous1 year ago
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.
could you pls provide some sample data?
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.
- Anonymous1 year agoNot 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.- Catman1 year agoFrequent Visitor
Hopefully this is a bit easier to understand.
Customer Invoice Total Amount by Customer Amount/Total Amount Paymentdays Average Payment Days by Customer Input Input Calculated - sum Amount for Customer Calculated Input Input Calculated
% * Paymentdays
A 10001 900,000.00 10.2054% 91,848 90 9 A 10002 900,000.00 37.5477% 337,929 45 17 A 10003 900,000.00 4.9367% 44,430 90 4 A 10004 900,000.00 39.5216% 355,695 45 18 A 10005 900,000.00 7.7886% 70,097 90 7 900,000 55 - Anonymous1 year agoNot applicable
Hi Catman ,
I have reviewed your values and performed the weighted average and total amount calculations using DAX .I got the below ouput: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.
- ryan_mayu1 year agoSuper User
you can upload to onedrive then share the onedrive link in the reply.