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

Show only selected week median

Hi all

I use the following expression to calculate the median volume for 6 weeks prior to the selected week.

median({<Week={">=$(=min(Week)-6)<=$(=max(Week)-1)"}>}Aggr(Sum({<Week={">=$(=min(Week)-6)<=$(=max(Week)-1)"}>} Volume), Store, Article, Week))

It works as it soppose to for now, as seen below:

    

StoreArticleVolume medianVolume current week
332105461113

I now want to add a dimension "week" but the I get the follwong result, I dont want to display all the weeks that the median is calculated on, only the row with the selected week (selected 16).

    

StoreArticleWeekVolume medianVolume current week
33210546106,00
332105461110,00
332105461216,00
332105461312,00
332105461414,00
33210546158,00
3321054616-13

I also want to select more than 1 week at the same time, but the I get this result (selected 15, 16):

  

StoreArticleWeekVolume medianVolume current
332105469180
332105461060
3321054611100
3321054612160
3321054613120
3321054614140
332105461588
3321054616-13

Has anyone got any ideas how I can solve it?

Br

//Christian

1 Solution

Accepted Solutions
sunny_talwar

My bad, there isn't a function like RangeMedian ... you can use RangeFractile instead

RangeFractile - script and chart function

View solution in original post

4 Replies
sunny_talwar

I think what you might need here is a RangeMedian function with Above() function... something like this

RangeMedian(Above(Sum({<Week>} Volume), 0, RowNo())) * Avg(1)

nictheswede
Contributor II
Contributor II
Author

Thanks for you answer but I'm not familiar with the RangeMedian function and I don't seem to find any information about it anywhere.

sunny_talwar

My bad, there isn't a function like RangeMedian ... you can use RangeFractile instead

RangeFractile - script and chart function

nictheswede
Contributor II
Contributor II
Author

Thank you Sunny, it solved a big part of the problem.