Jump to content

Ordering the row group from a crosstab with a position variable


kalvarez

Recommended Posts

Hi everybody!!

I´m using the ireport 4.0, and i like it, before i used the 3.6 and i see a lot of good changes.

What I need is ordering the row group from a crosstab, i have a variable "count" to put the number at the begining of each rows and  works ok, the problem is that  number rows  of the crosstab  are in a wrong order.

The bucket expression from my row group is:

$V{Count Variable}+". "+$F{my field}
order Ascending

Where $V{Count Variable} is an integer that counts my field...and thats works Ok, but the order is wrong!!

The result is something like this, you can see that the position 10 is in the second place, not in the tenth place how is right.

 

Univ. 2004 (€) 2005 (€)
1. UNIV UA -  0 168.836
10. UNIV USEV -  3.000 0
2. UNIV UAB -  8.574 0
3. UNIV UCOR -  0 1.984
4. UNIV UG -  14.742 0
5. UNIV UJI - 50.000 0
6. UNIV UL - 0 782.855
7. UNIV UPNAV -  0 4.539
8. UNIV UPVAL -  133.100 0
9. UNIV URJC - 250.000 0
Total  (€) 459.416 958.214


Any idea?, i think there is a simple solution but i can't find it... thks!!

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

It looks like it's sorting alphabetically, and since you're mixing numbers and text together, it's not surprising that it's treating your numbers at the beginning as text.  So everything that starts with a "1" will come before everything that starts with a "2", etc. regardless of how many digits there are.   One way to fix it is to pad each number to the left with zeroes if you can safely predict the maximum number you'll run into:

 

0001 UNIV UA -

0002 UNIV UAB -

...

0010 UNIV USEV -

etc.

There might be a way to pass an invisible column that handles the order, in which case it might be that such a column could be interpreted as a number, but I don't have a lot of experience doing fancy things with crosstab reports, so I don't know for sure.

Carl

Link to comment
Share on other sites

Thank you Carl, you´re right, the ireports treat numbers at the beginning as text but if set "data is pre sorted" even my text field is a string type, the sorting is correct, now my count variable works perfect...

Univ 2004 (€) 2005 (€)
1. UNIV UA -   0 168.836
2. UNIV UAB -  2.008.197 0
3. UNIV UCOR - 0 733.932
4. UNIV UG - 5.504.078 30.010.964
5. UNIV UJI - 8.139.486 0
6. UNIV UL - 0 4.394.443
7. UNIV UPNAV - 0 6.618.546
8. UNIV UPVAL - 11.950.900 105.415
9. UNIV URJC -   358.605 8.487.824
10. UNIV USEV -  185.208 95.000
Total (€) 28.146.473 50.614.961



thanks :D!!



Post Edited by kalvarez at 01/31/2011 08:45
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...