4 Replies Latest reply: Aug 18, 2011 8:02 AM by Toni Kautto RSS

    Dollar expansion of Median() in set expression

    Toni Kautto

      I am trying to calculated the sum of cost per item, only including costs that are equal or greater than the median cost per item.


      The obvious problem is that the dollar-expansion is calculated over the total data, so I attempted to make a simple Aggr() to group the result over Item.


      SUM({$<Cost={">=$(=aggr(median(Cost), Item)"}>}Cost)


      After numerous attempts of twisting and turning the expression around I have still failed to find a way to do this in a set expression, so I am now hoping that a set analysis genious in here could point me in the right direction. It seems like something quite easy to accomplish, so what am I missing out on here?


      In the attached QVW you can see that the result can be found by an Aggr(If(Median())) construction in the third column. So these are the expected results once the set expression expands and populates the second column. The Data table shows the loaded data.