2

Using Forena Reports I'm wondering if it's possible to include in a report the PARAMETERS passed by the URL?

I'd just like to output those parameters once in the report; probably at the top. Something like this:

You selected 'item a, item b, and item c'. (where items a,b, and c are the parameters passed).

Extra question: When I run the sample report with state=VA and then click 'CSV', the CSV download will not say which parameters were selected. Anyway to have the CSV download also include the parameters (+ their values) that were specified?

2

Display the value of a report parameter in the report

A sample of showing the values of the specified parameters can be found in reports/sample.user_distribution_simple.

If you execute that report with a parm like (eg) state=VA, or you just use an URL like /reports/sample.user_distribution_simple?state=VA, the report will contain a phrase like "This report lists all users in cities assigned to a state with code = VA.".

Line 26 in the .frx source of this sample that creates that phrase looks like This report lists all users in cities assigned to a state with code = {parm.state}.

So in this specific case, try something like this:

You selected 'item {parm.a}, item {parm.b}, and item {parm.c}'.

That is: preceed the parameter(s) with {parm. and have them followed by a }. Some more details about this:

  • The { and } are an indication you want to include something in your report about the report "context" (= Forena terminology).
  • The parm. part of it is to indicate "one of the report parameter values".
  • The a is to actually name the exact parameter (like 'a').

This technique (syntax) is also used to create "linked" reports (drill down reports, etc).

Here is a sample of one of my "custom" reports where I do something similar:

Watchdog Statistics

Within the "Report Execution Parameters" (collapsed in the screenprint above), I specify the search criteria of the log messages to be retrieved (the "8" within "... statistics within 8 most recent log messages ..." was the value of one of the parameters).

Include the value of a report parameter in the exported CSV file

The file saved via the CSV export feature, will actually include all the report data shown in the report as "tabular" format (which is compliant also with the tag description ...). So to get the report parameter (and the specified value) included in the CSV export file, you'd have to somehow include that in the appropriate area of your report.

As a sample, consider the reports/sample.user_distribution_simple again. You could enhance (customize) this report (which is specified using xHTML ...), by adding these extra HTML lines before the </table> tag:

<tfoot>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><b>Report parameters</b></td>
    <td><b>Parameter values</b></td>
  </tr>
  <tr>
    <td>state</td>
    <td>{parm.state}</td>
  </tr>
</tfoot>

In doing so, and by rerunning the report again with report parameter (say) state = VA, you should get a CSV export file that looks like so:

city,users
Amesbury,"3,991"
Catskill,"3,123"
Ketchikan,"6,107"
Michigan City,"1,741"
Selma,"1,833"
Vineland,"1,825"
 , 
Report parameters,Parameter values
state,VA

One could argue about the layout/format of the CSV output file (like the 3rd line from the bottom that only has a ","), but the keypoint is that you can use the full power of xHTML to enhance the layout to fit your needs. E.g. replace the &nbsp; (twice) with something more appropriate, or move those tfoot rows somewhere above the thead rows (to have the parms and values shown at the top of the CSV file.

  • thanks, this mostly answers my question. I notice when I do the sample report with state=VA as you put above, and then click 'CSV' the CSV download still doesn't say which parameters were selected. Anyway to make sure the CSV download also includes the parameters that were selected/passed by URL? – Sage Jul 24 '15 at 17:53
  • OK, we're making progress (again). And you added an interesting extra (bonus?) question, for which I don't know an answer by heart. Solution to the problem, changes the problem, right? Let me think /research AbitMORE about that, and maybe do some extra experiments by tweeking that sample report a bit ... – Pierre.Vriens Jul 24 '15 at 17:59
  • thanks for the follow-up. That worked for me! I'll customize it a bit to be formatted like we want. – Sage Jul 27 '15 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.