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

Finding median while ignoring 0 values

I'm trying to find the median of "Rental to sales" value by Name, ignoring the 0 values. 

However, I noticed the median function takes 0 values into consideration. How could I find the median value without the 0 values? Thanks.

 

My calculation for Rental to Sales:

(-1*
sum(aggr(
Sum({$<[PLLevel6]={'RENTAL'},Valid={'Y'}>}Amount),
[ID],[MonthYear])))
/
(sum(aggr(
if([Remote/Retail]='Remote'or [Category] = 'OCB',
Sum({$<[PLLevel5] = {'Sales'}>}Amount),

if([RetBranCategory]='Branch',
Sum({$<[PLLevel5] = {'Sales'},Valid={'Y'}>}Amount)+
Sum({$<[PLLevel5] = {'Sales'},Name={'TOTE'}>}Amount),
Sum({$<[PLLevel5] = {'Sales'},Valid={'Y'}>}Amount)
)),[MonthYear],[ID])))

 

Finding Median:

median(aggr((-1*
sum(aggr(
Sum({$<[PLLevel6]={'RENTAL'},Valid={'Y'}>}Amount),
[ID],[MonthYear])))
/
(sum(aggr(
if([Remote/Retail]='Remote'or [Category] = 'OCB',
Sum({$<[PLLevel5] = {'Sales'}>}Amount),

if([RetBranCategory]='Branch',
Sum({$<[PLLevel5] = {'Sales'},Valid={'Y'}>}Amount)+
Sum({$<[PLLevel5] = {'Sales'},Name={'TOTE'}>}Amount),
Sum({$<[PLLevel5] = {'Sales'},Valid={'Y'}>}Amount))),[MonthYear],[ID]))),[Name]))

1 Solution

Accepted Solutions
bethany_
Contributor II
Contributor II

Do you use the 0s elsewhere? You could change them in your load into a Null() rather than a 0 value so they are ignored by the formula.

View solution in original post

2 Replies
bethany_
Contributor II
Contributor II

Do you use the 0s elsewhere? You could change them in your load into a Null() rather than a 0 value so they are ignored by the formula.
yxchua
Contributor
Contributor
Author

Thanks! It worked.