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)
how do it write an expression for binding that meets this criteria?
gib65
<p>Hello,</p><p> </p><p>I'm wondering if there's a way to write an expression for the binding of my data element that works like this SQL query:</p><p> </p><p>select [FIELD_DATA] where [FIELD_NAME] = "blah"</p><p> </p><p>That is to say, I don't want the cell in my grid to be filled simply by iterating through the dataset and, for every row, grabbing the data under a specific column. I only want it to grab the data from that row, under that column, in the dataset if it meets the condition that some neighboring cell (call it "FIELD_NAME") equals some specific value.</p><p> </p><p>Can I do this?</p>
Find more posts tagged with
Comments
mwilliams
<p>This sounds like you would just need to add a filter on your table in the property editor? Let me know if I'm misunderstanding.</p>
gib65
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="120369" data-time="1379434886"><div><p>This sounds like you would just need to add a filter on your table in the property editor? Let me know if I'm misunderstanding.</p></div></blockquote><p> </p><p>Maybe,</p><p> </p><p>Keep in mind, it's a grid, not a table. And every row has a specific value associated with FIELD_NAME, a value that I will be hardcoding. If this can be done with filtering, then sure.</p>
mwilliams
<p>Oh. My mistake. You do want to not show the entire grid row if the check doesn't come out, though, correct? If so, a visibility expression on the grid row in the property editor would be the solution here.</p>
gib65
<p>Well, I'm not sure visibility has anything to do with it.</p><p> </p><p>Let me try explaining this in a different way:</p><p> </p><p>Suppose my Grid looks like this:</p><p> </p><p>
</p><p>| Field Name | Field Value |</p><p>
</p><p>| ABC............|....................|</p><p>
</p><p>| DEF............|....................|</p><p>
</p><p>| GHI.............|....................|</p><p>
</p><p> </p><p>You can consider the Field Name column to be populated by labels or text boxes (or something in which the text is hardcoded).</p><p> </p><p>Now, the order matters here. ABC must come before DEF which must come before GHI (but it's NOT alphabetical <-- keep that in mind).</p><p> </p><p>So suppose in my dataset, the data is orgranized this way:</p><p> </p><p>
</p><p>| Field Name | Field Value |</p><p>
</p><p>| GHI............| 123..............|</p><p>
</p><p>| ABC...........| 456..............|</p><p>
</p><p>| DEF............| 789.............|</p><p>
</p><p> </p><p>So let's go back to my grid. For the first row (where field name is "ABC"), I want to grab the field value from the second row of the dataset. So I'm thinking that what I have to do is drop a Data item into the second cell of the first row in my grid, which brings up the New Data Binding dialog, then click on the Expression button, then somehow enter an expression that does something similar to my SQL query in my OP, something that grabs the value 456 from the second row, second column of the dataset. All it needs to do is figure out which row in the dataset has "ABC" in the first column, and grab the data under the second column from that row.</p>
mwilliams
<p>Okay. I think I'm with you. One way to do this would be to store the dataset data into an array or into persistent global variables named by the other column's value. Then, you could recall this array or the appropriate pgv and display the appropriate value. in your grid.</p>
gib65
<p>Yeah, I could do this. It would be similar to creating a scripted dataset as you showed me how to do here: <a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/forum/index.php?/topic/30217-building-dataset-based-on-another-dataset/'>http://www.birt-exchange.org/forum/index.php?/topic/30217-building-dataset-based-on-another-dataset/</a>.</p><p> </p><p>I
might just do that.</p>
BRM
<p>If I understand correctly what you are essentially trying to do is to filter the dataset on the FieldName where various values of field name are hardcoded in the first column of the table. The complexity here is that the order of FieldName is not alphabetic or sequential in any way.</p><p> </p><p>If I have that right then another approach would be to use PGV's set in the elements of the first column to filter separate tables that are in the second column of the grid.</p><p> </p><p>Do you use SQL to get your main dataset? If so then another way to do this would be to specify the order of things in the SQL query and then you would be able to use simple table grouping when you get the data into BIRT.</p>
gib65
<p>Thanks both for your suggestions. They both seem like viable options. In the end, however, I went with a 2D array that stores the primary keys of the fields in its first column in the correct order. Then I tweak my query to include the primary keys in the results. So in the main dataset's onFetch handler, I scan the array for the key that matches the current row's key, and that's where I store the current row's field name and value (in the 2nd and 3rd column). Finally, I create a scripted dataset (along the lines of what mwilliams showed me in the link I posted above) in which I copy the contents of the array into it in the same order. That scripted dataset then becomes the dataset my table (not a grid anymore) uses to populate its rows.</p>