gotque Posted February 21, 2012 Share Posted February 21, 2012 Hello,Firstly, sorry for my english, I'm French and I will try to express myself the best possibleI try to do a crosstab rperenant the number of purchase per quarter in several stores of my group.In my SQL table I have this:ID | Date | Products |1 | 20080101 | Tshirt2 | 20090101 | Sweater3 | 20090104 | Tshirt...99 | 20120201 | ShoesMy goal is to have an array like this || 2008 || 2009 || ... || 1er | 2nd | 3eme | 4ieme || 1er | 2nd | 3eme | 4ieme || ... Tshirt || 1 | 2 | 4 | 3 || 0 | ....... | ....... | ....... || ...Sweater || 0 | ....... | ....... | ....... || 0 | ....... | ....... | ....... || ...Shoes || 0 | ....... | ....... |...... . || 0 | ....... | ....... | ....... || ...Total || 1 | .......| ....... | ....... || 0 | ....... | ....... | ....... || ...I succeed very well except when there isn't sale in one quarter. Indeed, if no sales are made ​​in one quarter (All lines to zero), the column does not appear.I want to make them appear even if it is zero.Have you the solution.I work in iReport 4.1.1thank youPost Edited by gotque at 02/21/2012 12:30 Link to comment Share on other sites More sharing options...
mennei Posted February 23, 2012 Share Posted February 23, 2012 Hi,How did you create the crosstab? How do you fill the "Measure"? (the data in the crosstab). Link to comment Share on other sites More sharing options...
gotque Posted February 24, 2012 Author Share Posted February 24, 2012 Thank you for your reply,So already my SQL query looks like this: SELECT SUBSTRING(RI_DATE_INSCRIPTION,1,4)) AS C_DATE, QUARTER(RI_DATE_INSCRIPTION) AS C_TRIM, C_PRODUCTS, COUNT(C_ID) AS NB_VENTEFROM CARNETGROUP BY C_DATE, C_TRIMHAVING CATEGORY IS NOT NULLORDER BY D_RANDO ASC; A little explanation:- C_DATE me back the years that I've extracted the fields RI_DATE_INSCRIPTIONEx: To date 20120101 (RI_DATE_INSCRIPTION), C_DATE = 2012- C_TRIM returns the number of quarterEx: 1,2,3 or 4- C_PRODUCTS represents the type of productEx: Shoes, T-Shirt ...- NB_VENTE counts the number of salesTo create the Crosstab I drag the Crosstab in Summary part and I get the following information:- Row 1 Group: C_PRODUCTS / UniqueRow 2 Group: None- Column 1 Group: C_DATE / singleColumn Group 2: C_TRIM / single- Data: Measure: NB_VENTE / Function: CountI put a preview of my problem as an attachment, you see that for 2004, only quarter 2 and 4 appear as During the quarter 1 and 3, no sale has taken place (no data in the table). Instead of automatically delete the column, I would like to see appear with that of 0.Thank you in advanceQG Link to comment Share on other sites More sharing options...
mennei Posted February 26, 2012 Share Posted February 26, 2012 some questions:1. Is the crosstab on the summery band and the query is the main query? Or you use dataset? 2. Is the query give you zero (in the 1,3 quarters for 2004), when you run it outside of iReport?3. What are the values you specify in the crosstab data? (right click on the corsstab element -> crosstab data) Link to comment Share on other sites More sharing options...
gotque Posted February 27, 2012 Author Share Posted February 27, 2012 1. Is the crosstab on the summery band and the query is the main query? Or you use dataset? Yes, my crosstab is in the summary band and the query described above is the main query 2. Is the query give you zero (in the 1,3 quarters for 2004), when you run it outside of iReport?Since there are no data for Quarter 1 and 3 of 2004, when I execute my query outside iReport, it returns me "No data found" what should be 0 in iReport, I think. 3. What are the values you specify in the crosstab data? (right click on the corsstab element -> crosstab data)See attachment file Thank you again QG Link to comment Share on other sites More sharing options...
mennei Posted February 27, 2012 Share Posted February 27, 2012 I think you should check number 2. If the query didn't return 0, how iReport will know to convert the "no data" to "0"?Also, when you choose the data musare in the report inspector window, you have the "Blank when null" attribute. The defualt is false, so in the default behavaior the "no data" will disapper.Good luck. Link to comment Share on other sites More sharing options...
gotque Posted February 27, 2012 Author Share Posted February 27, 2012 I understand that iReport can not do with it but why did not I get all the same on some line 0? That's why I do not understand. Sometimes it will not interpret the data with a 0 and sometimes not. What I want is a table with the years from 2002 to 2011, cut into 4 quarter but I'm not always the 4 quarter. I will try to change my request. thank you again Link to comment Share on other sites More sharing options...
am0rales Posted January 11, 2013 Share Posted January 11, 2013 I think you can resolve this issue by addding a UNION with the value of your measure to 0 to your query and aggregating then the result of that UNION. Then you have all the combinations of your quarters, even if you have no data for them.Example for your query: SELECT C_DATE, c_TRIM, C_PRODUCTS, SUM(NB_VENTE) AS NB_VENTEFROM((SELECT SUBSTRING(RI_DATE_INSCRIPTION,1,4)) AS C_DATE, QUARTER(RI_DATE_INSCRIPTION) AS C_TRIM, C_PRODUCTS, COUNT(C_ID) AS NB_VENTE FROM CARNET GROUP BY C_DATE, C_TRIM, C_PRODUCTS HAVING CATEGORY IS NOT NULL) UNION (SELECT SUBSTRING(RI_DATE_INSCRIPTION,1,4)) AS C_DATE, QUARTER(RI_DATE_INSCRIPTION) AS C_TRIM, C_PRODUCTS, 0 AS NB_VENTE FROM CARNET GROUP BY C_DATE, C_TRIM, C_PRODUCTS HAVING CATEGORY IS NOT NULL ) TUNION GROUP BY C_DATE, c_TRIM, C_PRODUCTSORDER BY D_RANDO ASC; Link to comment Share on other sites More sharing options...
kasunhnw Posted July 4, 2018 Share Posted July 4, 2018 Same issue no solution 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