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 the heart icon**
**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 heart 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
 APAC User Group
 12 Welcome
 36 Domo News
 9.6K Using Domo
 1.9K Dataflows
 2.4K Card Building
 2.2K Ideas Exchange
 1.2K Connectors
 338 Workbench
 250 Domo Best Practices
 11 Domo Certification
 460 Domo Developer
 47 Domo Everywhere
 100 Apps
 703 New to Domo
 84 Dojo
 Domopalooza
 1.1K 日本支部
 4 道場日本支部へようこそ
 22 お知らせ
 62 Kowaza
 295 仲間に相談
 649 ひらめき共有