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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.