Jump to content
Changes to the Jaspersoft community edition download ×

Grouping via Expressions and Variables


AndyDavis51

Recommended Posts

Grouping via Expressions

 

Hello All, need a bit of help or Guidance

 

I Have a CSV file that hold Category/ Sub Category / Price information all as readable strings. And have used “Ireports†to generate a report that groups on Category and them Sub Category and works and looks nice,

 

but our client wants to go one further and have the report passed three bits of information,

 

I guess this would be done via Variables (can get that bit) , These bit being the Main Category they are interested in and a Price range for that category say for Example

 

Main Cat = “Mens Suits†and priced between £50 and £150 pounds etc

 

Have used Ireports new Group wizard to try and do this but all I get is abends, but Syntax checks out ok , so I am missing something or not getting Sytanx correct.

 

So I want to group on

 

$f{MainCat} = “ a passed variable†and ${Price} > “x†and < “y†x and y are also passed variables

 

but price is a string so needs some form of conversion into float/double etc as would X and y above This has been driving me nuts for about 1 week and I still cannot get it.

 

Any examples of Grouping Syntax would be good it might give me a clue, where I am going wrong as that seems a normal report request from a client.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hi Andy,

 

Sounds like there is some confusion between filtering and grouping. The GroupBy expression allows you group related records, and all records that have the same return value for the GroupBy expression will be in the same bunch. In you example where the expression is ?$f{MainCat} = “ a passed variable†and ${Price} > “x†and < “y†you are going to have two groups, one for "true" and one for "false".

 

I think you want to filter the data, right? In other words, only show the data for items in the given category and in the price range. Normally you would pass that info to the query and let the datasource do the filtering, but you can't do that with a CSV file of data.

 

You might be able to add a printWhenExpression to the detail band to only print when the data matches your conditions, but I'm not sure if its evaluated on each iteration or not.

 

Finally, you pass values into a report via Parameters, not Variables.

 

-Barry

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...