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)
crosstab / script / switch dimensions
Ima
Hi,
I have a problem with crosstabs. Here the dimensions I use :
- Status
---> status (G, C, R)
- Geography
---> rythm ((North, South
---> continent (Asia, Europe, Africa ...)
My measure is a number of school by status (columns) and by geography (rows). I want the user to choose if the crosstab uses the rythm or the continent values :
1- He chooses to see the crosstab by rythm. So I want to use the rythm dimension and my crosstab rows are North and South.
2- He chooses to see the crosstab by continent. So I want to use the continent dimension and my crosstab rows are Asia, Europe, Africa ...
I thought about several solutions.
The solution I want to use is to dynamically change the crosstab dimensions via script. The problem here is that I can't change all the xml elements I want to (or i don't know how to do that) ; and I am not sure it is possible to do that with the birt object only (crosstab, measure, level ...). So, first of all I want to know if there is a way to do what I try to do ?
If my problem is not clear I can give more details.
Thanks,
--
Marie
Find more posts tagged with
Comments
mwilliams
Hi Marie,
If I'm understanding correctly, the best solution might be to create two crosstabs, one with one dimension and one with the other. Then, in your beforeFactory script, you can drop whichever crosstab you don't need based on the parameter the user selects.
Ima
Yes you well understood my problem.<br />
<br />
In my example there is one crosstab with two dimensions (geography and rythm). But in the reality I need three crosstabs (one for 2009, one for 2010 and the last for 2010 - 2009). Each crosstab have 5 dimensions. So with your solution I might create 15 crosstabs. It is why I'm looking for a solution with only one crosstab with 5 dimensions.<br />
<br />
I want to change my xml in the onPrepare crosstab script. Maybe it is possible with the DesignHandle. I can access some elements in my xml like <extented-item>, <property> ... But there is some nodes I don't find how to access. Here the node :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><extended-item extensionName="Crosstab" extensionVersion="2.5.0" name="mycrosstab">
[ ... some properties ... ]
<list-property name="boundDataColumns">
<structure>
<property name="name">nb_etablissement_Statut etablissement/statut etablissement</property>
<expression name="expression">measure["nb_etablissement"]</expression>
<property name="dataType">float</property>
<simple-property-list name="aggregateOn">
<value>Statut etablissement/statut etablissement</value>
</simple-property-list>
<property name="aggregateFunction">SUM</property>
</structure>
[ ... other structures ...]
</list-property>
</extended-item></pre>
<br />
Here how I get the list-property :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var list_prop = reportContext.getDesignHandle().findElement("mycrosstab").getListProperty("boundDataColumns");</pre>
<br />
Then I get my structure element :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var p1 = list_prop.get(0);
</pre>
I thought that p1 will be a StructureHandle but when I use the deboguer it seems to be a org.eclipse.birt.report.model.api.elements.structures.ComputedColumn. So when I use the StructureHandle methods it does not work.<br />
<br />
Maybe I don't use the right method. I will continue to search informations in the documentation.<br />
<br />
-- <br />
Marie
Ima
I found a solution.
With the DesignEngine api it is possible to change the xml and to switch my dimensions.
mwilliams
Ah, yeah, 15 crosstabs would be a lot.
In a simple world with only 2 options, my solution would have worked well, but not in your case. Glad you found a solution to your issue! Let us know whenever you have questions!
Birtsnew
Hi Ima,
Can you post the report. I have the same requirement(adding dimension and measures dynamically)?
Thanks
Sam.
Doremi
Hi Sam,
It's not the same account but I'm Ima. It will be difficult to give you the report but I can give you and try to explain you the script I use to do it.
I just need to find it if you need it.
Birtsnew
Hi,
Can you forward to the following mail id?
samashok12005@gmail.com
Thanks
Sam
akrueger
<blockquote class='ipsBlockquote' data-author="'Doremi'" data-cid="84172" data-time="1318842540" data-date="17 October 2011 - 02:09 AM"><p>
Hi Sam,<br />
<br />
It's not the same account but I'm Ima. It will be difficult to give you the report but I can give you and try to explain you the script I use to do it.<br />
I just need to find it if you need it.<br /></p></blockquote>
<br />
Hi Ima,<br />
Could you post the report or explain your scripting? I have the exact same requirement only that the user can chose an aggregation level and my crosstab needs to change based on whether they chose Day, Week, Month etc. I've been trying to change the group level based on my input parameter through an expression in the group level, but have had no luck so far.<br />
<br />
Thanks<br />
- Anita
mwilliams
I'll look into it, Anita. Though, it might be just as simple to build the crosstab from scratch in the beforeFactory script.
http://www.birt-exchange.org/org/devshare/deploying-birt-reports/1043-create-data-cube--xtab-de-api-example/
akrueger
Hi Michael,
I'll give this a shot. Thanks for the example.
- Anita
mwilliams
Let me know if you get stuck!