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
Kiro_2112
Frequent Visitor

Excluding Zeros from percentile calculation

Good day, 

 

I was hoping someone could help me, if its possible, to find a percentile excluding the zeros. The reason for this is - in certain columns I have a lot of zeros and would like to calculate the percentile without creating new tables without the zeros.

 

Below is the the calculations I currently have, and Sample data.

 

Thank you in advance!!!!:) 

 

 

Cost Score = (

Var perc1= PERCENTILE.INC('Table'[Cost], 0.20)
Var perc2= PERCENTILE.INC('Table'[Cost], 0.40)
Var perc3= PERCENTILE.INC('Table'[Cost], 0.60)
Var perc4= PERCENTILE.INC('Table'[Cost], 0.80)
var average_per_hosp = CALCULATE(AVERAGE('Table'[Cost]),ALLEXCEPT('Table','Table'[ID]))
return(
IF(average_per_hosp<=perc1,1,
if(average_per_hosp>perc1 && average_per_hosp<=perc2, 2,
IF(average_per_hosp>perc2 && average_per_hosp<=perc3, 3,
IF(average_per_hosp>perc3 && average_per_hosp<=perc4,4,5)
)
)
)
))
 
IDCost
58086500
6352430
58082510
1319380
58081970
58086261.49
58028814.76
58066826.16
58033496.41
  
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Create a new column like this and try percentile on that

 

new cost = if([Cost]=0, blank(),[Cost])

View solution in original post

4 REPLIES 4
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please change your original measure to this:

Cost Score = 
Var perc1= CALCULATE(PERCENTILE.INC('Table'[Cost], 0.20),'Table'[Cost]>0)
Var perc2= CALCULATE(PERCENTILE.INC('Table'[Cost], 0.40),'Table'[Cost]>0)
Var perc3= CALCULATE(PERCENTILE.INC('Table'[Cost], 0.60),'Table'[Cost]>0)
Var perc4= CALCULATE(PERCENTILE.INC('Table'[Cost], 0.80),'Table'[Cost]>0)
var average_per_hosp = CALCULATE(AVERAGE('Table'[Cost]),ALLEXCEPT('Table','Table'[ID]))
return
IF(average_per_hosp<=perc1,1,
if(average_per_hosp>perc1 && average_per_hosp<=perc2, 2,
IF(average_per_hosp>perc2 && average_per_hosp<=perc3, 3,
IF(average_per_hosp>perc3 && average_per_hosp<=perc4,4,5))))

The result shows:

15.PNG

Hope this helps.

 

Best Regards,

Giotto

 

Thank you for your reply, I've tried this it just gives an output of 1 and 5 only

Pragati11
Super User
Super User

Hi @Kiro_2112 ,

 

The only way I can think of right now is before doing any Percentile calculation on your data, create a sub-table, which has data only with non-zero value in the "COST" column of your table. The you can use your percentile calculation on this new table.

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

Create a new column like this and try percentile on that

 

new cost = if([Cost]=0, blank(),[Cost])

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.