Jump to content
We've recently updated our Privacy Statement, available here ×

bsiddiqui

Members
  • Posts

    5
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Downloads

Everything posted by bsiddiqui

  1. Yes, svenn is right. Whenever you want to display one of the two fields (e.g. either an image or some text), you can use the Print When Expression property in such a way that it will always be true for one of the two fields and false for the other. I demonstrated exactly how to do this in one of the recipes of my JasperReports Cookbook. Please see recipe titled Applying styles to your data based on a logical or mathematical condition of chapter 9 Using Mathematical and Logical Expressions (available for free download, just click here). Especially see steps 13 and 15 of the recipe. The Print When Expression property is very useful and can be used in many interesting and creative ways, together with the flexibility of mathematical and logical expressions that JasperReports offers. Chapter 9 demonstrates several ways of using the Print When Expression property. Cheers, bsiddiqui Author, JasperReports 3.6 Development Cookbook
  2. Hi, What you are doing effectively is designing a summary report in the form of a table, which does not show the actual data, but a summary of the data (just counts of records). I guess you are trying to use the Detail1 section of iReport designer (or the <detail> JRXML tag) to show the only row of your report, which is giving you trouble. For your application, the <detail> tag should not contain anything (except perhaps an empty <band> child tag) and therefore the Detail1 section should remain empty for this summary report. You will write your grouping expressions in the Column Header section of iReport designer (or the <columnHeader> JRXML tag). You also perhaps don’t need to define the group count variable. You just need to drop the field for which you defined the group into the group header section (the <groupHeader> child of your <group> JRXML tag). If you are using iReport, it will automatically detect that you are dropping something that has many values into a group header section, which is unusual. So iReport will show you a dialog asking what kind of value you want to display. From that dialog, you will select the count aggregation function. And that’s it, hopefully. If you have multiple groups with different expressions, you will drop all the fields or variables associated with those groups into the same group header. I think you will not need to use all the group header sections. Try this and post your findings. If you still face problem, better post your JRXML. Cheers, bsiddiqui Author, JasperReports 3.6 Development Cookbook
  3. Hi, Your second technique is totally different from the first. It is interesting to see why the first technique didn’t work and the second solved the problem. What you’re trying to do is to know how many customers bought how many products. Your database contains just line items, meaning one line for one product with a customer name. The first technique is irrelevant with the problem you are trying to solve, due to the way JasperReports processes database records. JasperReports processes data record-by-record and each record is processed only once. So you have just one chance of extracting and saving whatever information you want to fetch from a record, meaning one data-processing-go. In the first technique, you ordered-by customers in the query and used JasperReports grouping feature for each customer. So you got the count of products for each customer. This technique may have been useful if you wanted to find how many customers bought a specific-number-of-products. If this were the problem, you could have used JasperReports expressions to check if the number of products bought by a customer matches with your specific-number-of-products. And then you could have maintained a JasperReports variable to count the customers who bought your specific-number-of-products. But this is not your problem here. You want to find how many customers bought how many products, meaning you want to find all the customer_number and product_number pairs logically present in your line items database. You need one JasperReports’ data-processing-go to find one pair. And one data-processing-go is all that JasperReports offers you. So it is impossible to write a single Jasper report that can find all the pairs for you. You might have used a subreport in your master report, where the master report asks the subreport to perform one data-processing-go to find the number of customers buying a specific-number-of-products. And the subreport is called every time the master report finds another specific-number-of-products in your line item data. You second technique worked because you used a complex query to find all the product_numbers present in your line item data. Then it is a trivial task to group the product_numbers and find the number of customers who bought each of the product_numbers. bsiddiqui Author, JasperReports 3.6 Development Cookbook Post Edited by bsiddiqui at 09/12/2010 18:48
  4. Hello, I can tell you about two of my resources, which can perhaps help you: 1. My article "Creating a Report from XML Data using XPath", which demonstrates how to use XPath to fetch data from an XML file as fields and drop the fileds into a jasper report 2. "Calculating the sum and average of a column" receipe from chapter 9 of my recent JasperReports 3.6.0 Development Cookbook. This chapter 9 (Using Mathematical and Logical Expressions) is available for free download. You can read the "Calculating the sum and average of a column" recipe, which shows how to use variables and expressions to find sum and average. Other recipes of the chapter also demonstrate various aspects of using mathematical and logical expressions. You can perhaps combine the two recipes to solve your problem. If you need further help, please post your JRXML code, then I will try to give you exact advice about your problem. bsiddiqui Author, JasperReports 3.6.0 Development Cookbook
  5. JasperReports provides rich features to do everything from simple sum and average to complex mathematical calculations over whatever records you choose. And you can use all these features of JasperReports with iReport. My recent JasperReports 3.6.0 Development Cookbook demonstrates the whole *design procedure* of reports that require logical, mathematical, or statistical calculations. You may want to go through the sample chapter (titled "Using Mathematical and Logical Expressions") of the book that is available for free download: http://www.packtpub.com/sites/default/files/downloads/0769os-chapter-9.zip There are several small tricky steps that you have to perform in order to calculate the sum of a column. All of these steps in the correct order are demonstrated in the “Calculating the sum and average of a column” recipe of the sample chapter. Please try the recipe. One more thing: When you have to convert a String stored in a database into an Integer in order to do a calculation in jasper reports, you can use the Integer.parseInt($F{YOUR_STRING_FROM_DATABASE}) Java static method in the expression of a variable. This expression simply returns the Integer form of your String variable.
×
×
  • Create New...