Similar idea, but since not all locations have all models, it's better to have a sparse representation rather than the full 3-d array. Basically, you'd have the indices and the values:
area store model sales i0 j0 k0 s0 i1 j1 k1 s1 etc. Once you have the appropriate representation, it's relatively straightforward to format it in the way you described. ----- Original Message ----- From: June Kim <[EMAIL PROTECTED]> Date: Saturday, May 17, 2008 11:23 Subject: [Jprogramming] 3-dimensional (was Re: 2-dimensional summary report) To: Programming forum <[email protected]> > Now suppose you have to analyze with another axis, in addition > to the > previous two axes. > > Look at the following data: > > data=: 0 : 0 > area model sales store > north T2 3 1001 > south T2 4 2120 > north T3 10 1001 > north T3 5 1001 > east T1 1 3012 > west T3 1 3029 > south T2 11 2123 > north T4 2 1002 > west T3 1 3030 > east T4 1 3012 > west T4 6 3031 > ) > d=: (<a:;<2) ((".&.>)@{)`[`]} }. cut;._2 data > > > Each model is sold at a specific store which is located at a specific > area. Each store is unique and it can't belong to a multiple of areas. > However, many transactions can happen at the same store, as you see > above in the data. > > What I need is the following report(it doesn't have to be pretty > -- > all I need is essentially the information, not the pretty formatted > report, though): > > area store T2 > T3 T1 T4 > --------------------------------- > north 1001 3 > 15 0 0 > > 1002 0 > 0 0 2 > north total 3 > 15 0 2 > > south 2120 > 4 0 0 0 > > 2123 11 > 0 0 0 > south total 15 > 0 0 0 > > east 3012 > 0 0 1 1 > east total > 0 0 1 1 > > west 3029 > 0 1 0 0 > > 3030 0 > 1 0 0 > > 3031 0 > 0 0 6 > west total > 0 2 0 6 > > > Now it got quite complexed, and I wonder what is the proper approach > to this kind of problems in J. > > > 2008/5/17, June Kim <[EMAIL PROTECTED]>: > > Suppose the data is given as following: > > > > data=: 0 : 0 > > area model sales > > north T2 3 > > south T2 4 > > north T3 10 > > north T3 5 > > east T1 1 > > west T3 1 > > south T2 11 > > north T4 2 > > west T3 1 > > east T4 1 > > west T4 6 > > ) > > d=: (<a:;<2) ((".&.>)@{)`[`]} }. cut;._2 data > > > > > > What I want is a report of sales for area by model: > > > > > NB. T2 T3 T1 T4 > > NB. north 3 > 15 0 2 > > NB. south 15 > 0 0 0 > > NB. east > 0 0 1 1 > > NB. west > 0 2 0 6 > > > > > > The final matrix doesn't need to contain row, column-headers -- > it is > > fine that it contains only the sales total for each area and model > > pairs. > > > > I'd like to know easy and simple ways to getting that matrix > in J. > > What's your suggestion? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
