How does the filter in Birt work

newbie321
edited February 11, 2022 in Analytics #1
<p>Hi, </p>
<p> </p>
<p>I am hoping someone could please explain to me <u>how </u>the filter in BIRT works.  Note, I know <strong>what </strong>filtering does - I need to know <strong>how</strong> to it works.  </p>
<p> </p>
<p>I am trying to apply the filter to a table and this filter is to be based on a variable which is a function of the table's row content (but has no contextual relation to table row content). Example, if row["myrow"] = "phone", then the variable value is "elephant".  </p>
<p> </p>
<p>I did some tinkering, and was able to trace that the Filter fires before table's rows ever get created, but after .beforeFactory(), as shown below:  </p>
<p> </p>
<div>
<pre class="_prettyXprint">
.initialize() fired...
       .onPrepare() fired...
               .TABLE.onPrepare() fired...
                       .TABLE-ROW.onPrepare() fired...
       .beforeFactory() fired...
               Filter invoked on: "phone"
  Filter invoked on: "pc"
  Filter invoked on: "usb"
      .TABLE.onCreate() fired...           
                   .TABLE-ROW.onCreate() fired...
  .TABLE-ROW.onCreate() fired...
  .TABLE-ROW.onCreate() fired...</pre>
</div>
<p>My questions are:</p>
<p>1) how do the Filters have a knowledge of the row's value 'a priori' to row's creation?  if the row's content is only available at .onCreate() event, does the filter then scan the underlying dataset?</p>
<p> </p>
<p>2) is it possible to configure the filter based  on a variable that changes as a function of row's content.  The simplest example would be:  let's say I want to count the number of rows and  apply the filter on that count.  Obviously, the number of rows will not be known up until .onCreate() gets fired and the counter counts those.  But by the time the counter obtains a value different from its initialized state in the .OnCreate() event, it already would be too late since the Filter get's an assignment after .beforeFactory() and before .OnCreate().  </p>
<p> </p>
<p>Interestingly enough, when I <strong>do</strong> use RUNNINGCOUNT to count the number of rows, the Filter <strong>does </strong>see the exact structure of the table correctly before the rows ever get created (how does it do that??) </p>
<div>
<pre class="_prettyXprint">
.beforeFactory() fired...
         Filter invoked on: 1
         Filter invoked on: 2
         Filter invoked on: 3
         Filter invoked on: 4
         Filter invoked on: 5
         Filter invoked on: 1
         Filter invoked on: 2
.TABLE.onCreate() fired...
New Group...
                  .TABLE-ROW.onCreate() fired...
.TABLE-ROW.onCreate() fired...
New Group...
.TABLE-ROW.onCreate() fired...
.TABLE-ROW.onCreate() fired...</pre>
<p>Thanks!! </p>
<p> </p>
</div>
<p> </p>

Comments

  • <p>Hello newbie321,</p>
    <p> </p>
    <p>I seem to be lost as to what exactly you are looking to do.</p>
    <p>Your example says:  <span style="color:#ff0000;"><span style="font-family:'Source Sans Pro', sans-serif;">if row["myrow"] = "phone", then the variable value is "elephant".  </span></span></p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">What variable are you indicating for elephant?  Is that the table's filter that is applied to the data binding?  Or a Group Row filter? Or other?</span></p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Would you happen to have an example rptdesign file with more details as to what the end result you are looking for is?</span></p>
    <p> </p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Also you said:  </span><span style="color:#ff0000;"><span style="font-family:'Source Sans Pro', sans-serif;">Interestingly enough, when I </span><strong>do</strong><span style="font-family:'Source Sans Pro', sans-serif;"> use RUNNINGCOUNT to count the number of rows, the Filter </span><strong>does </strong><span style="font-family:'Source Sans Pro', sans-serif;">see the exact structure of the table correctly before the rows ever get created (how does it do that??) </span></span></p>
    <p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">I believe this occurs on the table's binding rather than the table rows itself.</span></p>
    Warning No formatter is installed for the format ipb