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)
set variable to count of dataset
baseball43v3r
<p>I would like to show a table depending on the amount of results a dataset returns. I have created an aggregate column that counts the rows in the dataset but how do I then set the variable to that count? I am doing this inside the BIRT designer so onFecth() wouldn't work here. Is there something in the edit datatset that would allow me to do this?</p><p> </p><p>Mike Williams posted this in another thread and this is what I'm basing it off of but I'm stuck setting the variable.</p><blockquote class="ipsBlockquote"><p> </p><p>To hide a report element if there is no data in your result set, you could create a variable with a value of 0 in your initialize method of your report, increment the variable in the onFetch method of your dataSet, and then use this value to hide your chart/table if the value of the variable is 0 (this would mean that the onFetch was never called because there was not data to be retrieved).</p></blockquote><p> </p>
Find more posts tagged with
Comments
BRM
<p>Select the table and select the visibility tab. Then set the visibility expression to whatever condition you want to hide the table. The aggregate column need to be bound to the table. </p>
baseball43v3r
<p>Sorry I should have been more clear. Yes using the visibility tab is exactly what I plan on doing. I created a variable but now I don't know how to set the variable to be equal to the aggregate column. I want to use a variable because I want to hide an unrelated table that would not be bound to the aggregated column.</p><p> </p><p>edit: just checked and I've created a computed column, that is aggregated on COUNT... does that make a difference?</p>
BRM
<p>You can use persistent global variables to port values around the report so they can be reused.</p><p> </p><p>In the onCreate script of the aggregation element:</p><p>reportContext.setPersistentGlobalVariable("myVar", this.value);</p><p> </p><p>in the visibility tab for the element you want to conditionally hide</p><p> </p><p>reportContext.getPersistentGlobalVariable("myVar")=="0"; (if you wanted to hide the element for 0 records returned, note that the PGV returns a string, not an integer.</p><p> </p><p>Hope that helps. </p>