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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
harib
Post Patron
Post 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

2 ACCEPTED SOLUTIONS
Anonymous
Not 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

View solution in original post

TeigeGao
Solution Sage
Solution Sage

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

View solution in original post

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

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

Anonymous
Not 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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.