Forum Discussion
harib
7 years agoPost Patron
Average with if condition
Hello Friends,
Sample table here. I need a average from Returns (Qty), Shipped (Qty)
Returns (Qty) : 3296
Shipped (Qty) : 18732408
Rate (%) : 0.21%
Rate (%) =If [Shipped (Qty)]=0 Then 0 Else 12 * [Returns (Qty)] / [Shipped (Qty)] + 0
Can we get average with if Condition like above formula.
Thanks in Advance
- Anonymous7 years ago
harib - The DIVIDE function has 3 parameters - Numerator, Denominator and Alternate Result. You could create a measure like this:
Rate (%) = var num = SUM([Returns (Qty)]) * 12 var den = SUM([Shipped (Qty)]) return divide(num, den, 0)
Hope this helps,
Nathan
Hi harib ,
We can also use the IF() function.
Rate (%) = IF ([Shipped (Qty)]=0 , 0 , 12 * DIVIDE([Returns (Qty)] ,[Shipped (Qty)] )+ 0)
Best Regards,
Teige
2 Replies
- AnonymousNot applicable
harib - The DIVIDE function has 3 parameters - Numerator, Denominator and Alternate Result. You could create a measure like this:
Rate (%) = var num = SUM([Returns (Qty)]) * 12 var den = SUM([Shipped (Qty)]) return divide(num, den, 0)
Hope this helps,
Nathan