Weighted Average formula  beast mode
Hi all
I am using a beast mode to calculate the weighted average of days between two dates (payment due date and invoice date). Formula here: SUM((`PAYMNT_DUE_DT``INVOICE_DT`)*`RECPT_AMT_USD`)/ SUM(`RECPT_AMT_USD`)
However, I realized there may be some zeros in the output that are possibly causing the weighted average to be skewed lower. Can someone let me know if there is something I should add to exclude zeros maybe?
Answers

Sum(Case when (your function) = 0 then 0 else (your function) end)
0 
You can use a CASE statement to filter some values in your calculation. See
CASE WHEN `value_or_expression` <> 0 THEN `value` END
Alternatively you could use the filter on your card to filter out other values.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 
SUM((`PAYMNT_DUE_DT``INVOICE_DT`)*`RECPT_AMT_USD`)/ SUM(`RECPT_AMT_USD`)
I don't believe your problem is the existence of zeros. Or att least, perhaps not the way you're explainig it anyway.
1) i assume payment_due_dt is a dateTime column. If so, you shouldn't do dtdt, I'm not sure it's reasonable to assume that Domo will calculate the difference between two dates. Instead, use the DateDiff function. Be clear if it's dateTime or just date, b/c you might get a decimal result if it's less than a complete date.
Lastly, what happens if payment came in on the same day as the invoice? then, yes the datediff is zero, so i assume that's where you want your CASE statement, if datediff = 0 then 1 else datediff end.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
 10.6K All Categories
 13 Getting Started in the Community
 31 Beastmode & Analytics
 2.1K Data Platform & Data Science
 59 Domo Everywhere
 2.7K Charting
 2.4K Ideas Exchange
 1.3K Connectors
 362 Workbench
 301 Use Cases & Best Practices
 500 APIs
 118 Apps
 48 News
 753 Onboarding
 1.1K 日本支部
 Private Company Board