psentosa Posted April 29, 2010 Share Posted April 29, 2010 Hi all,I'd like to print a report (Shoe order for a certain model) which have the following form:Model AShop name OrderShop1 33 35 37 38 2 2 5 9Shop2 31 32 38 42 44 1 2 3 5 6 As you can, each records contains following information:1. The name of the shop that give the orders2. Amount of the shoes pair for each ordered sizeThere are so many different sizes, and any shop should order shoes in certain sizes that they currently need; so the number of the columns for the table in the "Order"-Column should be dynamic.Any advices on how to create the table?FYI, I use java data source for the report, so in this case I will have a data model such as: public class OrderDataEntry {String shopName;/** the key of the map is the size, and the value is the amount*Map<Integer, Integer> shoeOrders;} Thanks in advance Post Edited by psentosa at 04/29/2010 14:45 Link to comment Share on other sites More sharing options...
lucianc Posted May 4, 2010 Share Posted May 4, 2010 You could use a crossab for that, but you'd need to change your model in order to produce records that contain shop name, size and order count as fields.Regards,Lucian Link to comment Share on other sites More sharing options...
psentosa Posted May 4, 2010 Author Share Posted May 4, 2010 Hi Lucian, thanks for your reply.Do you mind giving some more hints on this? Thanks in advance Link to comment Share on other sites More sharing options...
lucianc Posted May 4, 2010 Share Posted May 4, 2010 See demo/samples/crosstabs in the JR distribution to get an idea on how crosstabs work.As I was saying, in order to use a crosstab you'd have to change your data source to produce records like these:Shop1, 33, 2Shop1, 35, 2Shop1, 37, 5Shop2, 31, 1Shop2, 32, 2...If you can do that, you'd then define a crosstab that has the shop as row group, the size as column group and the count as measure.Regards,Lucian Link to comment Share on other sites More sharing options...
psentosa Posted May 4, 2010 Author Share Posted May 4, 2010 Hi Lucian, again, thanks a lot for your reply.One last question, actually the records are a little bit more: Model AShop name Order Delivery PriceShop1 33 35 37 38 10.11.2012 100 2 2 5 9Shop2 31 32 38 42 44 12.10.2012 200 1 2 3 5 6 So, as you can see, actually there are some more columns; using "your model",is it ok to have the records like this:Shop1, 33, 2, 10.11.2012, 100Shop1, 35, 2, 10.11.2012, 100Shop1, 37, 5, 10.11.2012, 100Shop2, 31, 1, 12.10.2012, 200Shop2, 32, 2, 12.10.2010, 200And as there are some columns now, how to decide which 2 are the column groups and how to determine the row group?Many many thanks! Regards Link to comment Share on other sites More sharing options...
lucianc Posted May 5, 2010 Share Posted May 5, 2010 That adds some complexity because the case diverges from what crosstabs were meant to do.But you can still do it by adding the delivery and price values as measures (use calculation="Nothing" for them), and displaying them in the row total cell.I know this is getting a liitle too complex, but I don't see other feasible solutions. You could a horizontal list to display the size order values, but that doesn't allow you to push to the right the delivery and price text fields.Regards,Lucian Link to comment Share on other sites More sharing options...
psentosa Posted May 14, 2010 Author Share Posted May 14, 2010 Hi Lucian,thanks for your hints.I managed to create the table I want.Just a further question, that you could answer if you have some spare time :) :Actually there are some more columns beside delivery and price, two of which are related with the price: unit price total price unit price is a fix value, while total price is based on the sum of the number or ordered shoes, so it would look like: Amount Unit Price Total price33 35 37 392 2 2 2 8 15 120I still manage to get the amount value right (by using calculation type "Sum" on the number measure, but is there any possibilty to automaticall calculate the total price?Thanks and have a nice weekend! Regards Link to comment Share on other sites More sharing options...
shaded Posted May 14, 2010 Share Posted May 14, 2010 I've been trying to create a dynamically sized table just like yours for a while now, would you mind posting how you got it to work? In the past I've only been able to solve it by brute forcing it and creating different column headers / detail frames for each condition... not very efficient. Link to comment Share on other sites More sharing options...
psentosa Posted May 15, 2010 Author Share Posted May 15, 2010 Hi Shaded..what I did is exactly what Lucian has recommended:using crosstabs, and define your dynamic columns as column groups..further I set the rest of the columns which are static (i.e only 1 column) as measures...try to play with the crosstabs a bit and you'll get what I mean Cheers Link to comment Share on other sites More sharing options...
lucianc Posted May 18, 2010 Share Posted May 18, 2010 psentosaWrote: I still manage to get the amount value right (by using calculation type "Sum" on the number measure, but is there any possibilty to automaticall calculate the total price? Why can't you just multiply the two values? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now