Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Help on Sorting
Bharath406
Hi,
I have the following 3 labels that will be displayed on x-axis of a chart.
"< 7 days", "7 to 30 days", "> 30 days". But if I do sorting, they will be displayed in different order. But I want them to be in the same order I specified. How can I achieve.
I have the same issue on the cross tab as well. The rows needs to be
< 7 days
7 to 30 days
> 30 days
Any help is appreciated.
Find more posts tagged with
Comments
mwilliams
Hi Bharath406,
If you create a computed column that ranks them in the order you want them to be (1 for <7, 2 for 7 - 30, etc.), you can sort based on this column.
Note: In the crosstab, you'll need to go into the dataCube, "edit" the dimension you're wanting to sort, and add this new field as an attribute to that field, so it can be used in the crosstab.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69321" data-time="1286994580" data-date="13 October 2010 - 11:29 AM"><p>
Hi Bharath406,<br />
<br />
If you create a computed column that ranks them in the order you want them to be (1 for <7, 2 for 7 - 30, etc.), you can sort based on this column.<br />
<br />
Note: In the crosstab, you'll need to go into the dataCube, "edit" the dimension you're wanting to sort, and add this new field as an attribute to that field, so it can be used in the crosstab.<br /></p></blockquote>
Hi Michael,<br />
I'm missing something. I created the computed column and as you said, it is working fine with the cross tab. But I can't do that for Chart (adding it as an attribute or selecting it for sorting)
mwilliams
Can you not choose the sorting button next to the x-axis category and use the expression builder to select the other column in the sort condition? If not, you'll need to put the 1,2,3 field into the x-axis category and then just replace the labels with script.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69327" data-time="1286996101" data-date="13 October 2010 - 11:55 AM"><p>
Can you not choose the sorting button next to the x-axis category and use the expression builder to select the other column in the sort condition? If not, you'll need to put the 1,2,3 field into the x-axis category and then just replace the labels with script.<br /></p></blockquote>
Thatz right. I can't select the expression builder. Do you have an example which shows how to access X-axis labels
mwilliams
What's your BIRT version? I'll make a quick sample.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69332" data-time="1286997148" data-date="13 October 2010 - 12:12 PM"><p>
What's your BIRT version? I'll make a quick sample.<br /></p></blockquote>
2.3.2.2
mwilliams
I was able to sort by the new column. You can see in the attached report. Are you using optional y-series grouping? I think that makes the sort field option disable.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69340" data-time="1287004966" data-date="13 October 2010 - 02:22 PM"><p>
I was able to sort by the new column. You can see in the attached report. Are you using optional y-series grouping? I think that makes the sort field option disable.<br /></p></blockquote>
Yes Michael, I'm using optional y-series grouping. I have a script that can access this optional y-series labels and I can manipulate them. But donno how to get hold of the other labels(x-axis or y-axis)
mwilliams
Bharath,
Ok, then you should be able to do something like this in your chart script for your labels:
function beforeDrawAxisLabel( axis, label, icsc )
{
if (label.getCaption().getValue() == "1"){
label.getCaption().setValue("< 7")
}
}
Let me know.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="69368" data-time="1287066974" data-date="14 October 2010 - 07:36 AM"><p>
Bharath,<br />
<br />
Ok, then you should be able to do something like this in your chart script for your labels:<br />
<br />
function beforeDrawAxisLabel( axis, label, icsc )<br />
{<br />
if (label.getCaption().getValue() == "1"){<br />
label.getCaption().setValue("< 7")<br />
}<br />
}<br />
<br />
Let me know.<br /></p></blockquote>
Thanks Michael. It works.
mwilliams
You're welcome!