vba - SSRS - Median by Group - Jagged Array? -


i'm faced challenge in 2 parts. i've been requested replace 3 columns in matrix aggregates on name in row group. 3 columns outside of column group.

challenge 1 - matrices want summarize data pane. there seems no way show raw data (and hide it, in order these rows during runtime populate array).

challenge 2 - need calculate median name. means either, during runtime, need calculate 1 median each name @ time, reset array, , start fresh next name value, or, need multi-dimensional array each ordinal array corresponding name.

i'm total code monkey @ vb.

here's i've borrowed online post calculating median in ssrs.

    dim values system.collections.arraylist      function addvalue(byval newvalue decimal)         if (values nothing)             values = new system.collections.arraylist()         end if         values.add(newvalue)     end function      function getmedian() decimal         dim count integer = values.count         if (count > 0)             values.sort()             getmedian = values(count / 2)         end if     end function 

i think have sql solution doesn't utilize loop.

;with counts (    select salesperson, c = count(*)    dbo.sales    group salesperson ) select a.salesperson, median = avg(0.+amount) counts cross apply (    select top (((a.c - 1) / 2) + (1 + (1 - a.c % 2)))       b.amount, r = row_number() on (order b.amount)    dbo.sales b    a.salesperson = b.salesperson    order b.amount ) p r between ((a.c - 1) / 2) + 1 , (((a.c - 1) / 2) + (1 + (1 - a.c % 2))) group a.salesperson; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -