Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Defining a variable for use in aggregation filters
Defining a variable for use in aggregation filters [message #1203255] Fri, 22 November 2013 15:10 Go to next message
Justin Husted is currently offline Justin HustedFriend
Messages: 4
Registered: November 2013
Junior Member
Hello,

I am attempting to define a variable that will be used in multiple aggregations under the filter expression. The variable is always the exact same array:

a = ['HOL','HLW','HLA'] 


I can definite the variable in each individual aggregation, but this seems tedious and could be a little inconvenient if they ever needed to be updated. So I've been attempting to define the variable in one single location, but I keep receiving a "variable a is not defined" error when I attempt generate the report.

I've tried putting it in the entire row (group footer) using the script tab on both onPrepare and onCreate, but without success. I also tried defining it in the detail rows as Dynamic Text. Lastly, I tried entering it in the "Named Expressions" property for the entire chart. None of these have resolved the error.

My question is, where do I define the variable so that it can be used in the group aggregations?

Example:

index.php/fa/16798/0/

Thanks for your help!

Re: Defining a variable for use in aggregation filters [message #1204938 is a reply to message #1203255] Sat, 23 November 2013 10:31 Go to previous messageGo to next message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
There is a "Variables" section in the outline view where we can define such global elements.
As you can see on your second screen there is a "Variables" element in the palette.
For example:
- Create a new variable named "myListFilter"
- Set the list of values in the "default value" property,
- We can access it from any place in the report with the expression
vars[myListFilter]
Furthermore, these variables can be graphically dragged in the expression builder of any BIRT element, which is very convenient.


By the way, i believe "indexOf" is a method for Strings but not for Arrays, don't use brackets. Just in case with an array:

vars["myListFilter"].join(',').indexOf('HLW');


Re: Defining a variable for use in aggregation filters [message #1209600 is a reply to message #1204938] Mon, 25 November 2013 15:56 Go to previous message
Justin Husted is currently offline Justin HustedFriend
Messages: 4
Registered: November 2013
Junior Member
That was exactly what I was looking for, thank you!

Followup question, is there a way to automate the process of building groups that are similar, but that use a different datasetrow for their expression?

Example:

index.php/fa/16812/0/

I have to build an aggregation for each day but they are all similar, the only thing that changes is the data field - which is the day of the month #. I've had limited luck with concatenating the source code in Excel and then pasting it into the XML and am concerned about corrupting the report.

It looks like I can change these two sections:

The expression structure:

                <structure>
                    <property name="name">4 - Time Code</property>
                    <property name="dataType">float</property>
                    <property name="aggregateFunction">SUM</property>
                    <list-property name="arguments">
                        <structure>
                            <property name="name">Expression</property>
                            <expression name="value" type="javascript">row["4"]</expression>
                        </structure>
                    </list-property>
                    <property name="allowExport">true</property>
                </structure>


and the cell contents:

                        <cell id="3646">
                            <data id="3765">
                                <property name="fontSize">10px</property>
                                <property name="fontWeight">bold</property>
                                <property name="textAlign">center</property>
                                <property name="resultSetColumn">4 - Emee</property>
                            </data>
                        </cell>


Is there a better way to do this without using the UI?

I'll probably end up using the UI for all 31 columns in this case, but it would be good to know for future projects.

Thanks again!

Previous Topic:Displaying dynamic image in a report
Next Topic:HTML in cross tab?
Goto Forum:
  


Current Time: Fri Apr 19 20:02:22 GMT 2024

Powered by FUDForum. Page generated in 0.02938 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top