BIRT Exchange Forum: Strings in Crosstab Summary Field - BIRT Exchange Forum

Jump to content


 

No Latest Open Poll.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Strings in Crosstab Summary Field Rate Topic: -----

#1 User is offline   sbanaszak Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 15-September 08


Posted 30 November 2008 - 08:20 PM

Hello everyone,

I am doing a report and I think I have to use a crosstab.

Quote

The result should be something like this:
_________________|Type1|Type2|Type3|Type4|........
SECTION1__________UN_____AP____AP____UN__.....
SECTION2__________AS_____UN____UN____UN__.....
.
.
.


On the left side should be the list of road sections and in the columns there should be the assessment codes listed by type.

I understand that I can't use strings in summary fields so I made a computed column that would convert the codes to numbers like this:

Quote

UN -> 1
AP -> 2
...


Then in the expression builder for the summary field I put in this script:

Quote

if (dataSetRow["asses_number"] == "1" )
{UN}
else if (dataSetRow["asses_number"] == "2")
{AS}
else if (dataSetRow["asses_number"] == "3")
{AP}
else if (dataSetRow["asses_number"] == "4")
{DE}
else if (dataSetRow["asses_number"] == "5")
{HL}
else if (dataSetRow["asses_number"] == "0")
{0};


to convert it back to strings.

This doesn't work :/

Anyone got any ideas?

Thanks a lot!
0

#2 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 13105
  • Joined: 16-May 08


Posted 01 December 2008 - 07:48 AM

Hi sbanaszak,

What version of BIRT are you using?
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#3 User is offline   sbanaszak Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 15-September 08


Posted 01 December 2008 - 01:22 PM

I'm using 2.2.1 but I can't get it to work in 2.3.1 either :/
0

#4 User is offline   sbanaszak Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 15-September 08


Posted 03 December 2008 - 02:08 PM

*bump* :)

I'm desparate :/
0

#5 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 13105
  • Joined: 16-May 08


Posted 05 December 2008 - 09:07 AM

sbanaszak,

If you already have the integer values correct in your crosstab. In BIRT 2.3 and higher, you can change the value in the measure item's OnCreate script with an if/else statement like the following:


if (this.getValue() == 1){

this.setDisplayValue("UN");

}

else if (this.getValue() == 2){

this.setDisplayValue("AS");

}

...

...

etc.




I have not found a way to do this with older versions. I'm pretty sure that the upgrades to crosstabs in 2.3 made this possible.

Let me know if you have any other questions.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#6 User is offline   sbanaszak Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 15-September 08


Posted 07 December 2008 - 09:25 PM

Thanks a lot Michael, it now works great in 2.3.1.. So there's probably no way of avoiding the upgrade to 2.3.1..

Do you know of any way to disable the window that pops up everytime I preview the report and says "This report contains errors do you really want to run blablabla"? Or is there a way to actually find out what the error is?

Regards,
Stan
0

#7 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 13105
  • Joined: 16-May 08


Posted 08 December 2008 - 07:30 AM

Stan,

I would assume it would just be a problem with some script you have somewhere in your report. You may just want to look over all your bindings and scripts closely to see if you see any problems. I'd have to look at the report to see if I see anything. I won't be able to run it though. Would just be able to look it over.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#8 User is offline   smb Icon

  • Junior Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 03-April 09


Posted 04 April 2009 - 03:41 PM

I appreciate if some BIRT expert can help me on similar topic. (I'm a newbie to BIRT)
I tried several searches but not able to land on best solution. This topic took my attention as it sounded similar and may define the way ahead for the issue I need to resolve.

I would like to display string data in the crosstab for the summary field. However these strings are dynamic and stored in database against a crosstab intersection. Hence above solution doesn't help to resolve in the case I have.

Example my table is like as below....

ID TYPE STATUS
================
1 A Pass
1 B Fail
2 A Pass
2 B Pass
2 C Fail


Resulting report I am interested in as follows : (I tried cross tab...)

A B C
=================
1 | Pass Fail
2 | Pass Pass Fail

Number of rows and columns in above report are dynamic and can be determinde only at runtime and bound to changes too. (i.e "TYPE" values are dynamic)

I was trying crosstab but stuck with unable to display string (crosstab expects double in summary field) as per the column "STATUS".

Please someone guide me if I can achieve this using crosstab , may be some rendering or event handling after crosstab generation.

Also suggest alternate solution if crosstab isn't the right way.

Thanks in advance
-smb
0

#9 User is offline   HPP Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 62
  • Joined: 11-February 11


Posted 28 May 2012 - 01:40 AM

hi smb,

I guess u have to change the data type of the summary filed to string and funtion to first.


with regards,

hpp
0

#10 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 13105
  • Joined: 16-May 08


Posted 01 June 2012 - 12:28 PM

Yep. Just like HPP said. Take a look at this example. I use your data in a scripted dataSet, so don't worry about the script in the dataSet. That's just to get data exactly like your example. What you need to look at is the dataCube. Double click on the dataCube in the Data Explorer, then double click on the measure field, you'll see that the FIRST aggregation is selected and the field type is String. This report was designed in BIRT 3.7.2.

Attached File(s)


Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users