How to display the value of a report parameter in a Forena Report and in a CSV export of it? 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?
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:



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 csv 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 &lt;/table&gt; tag:

&lt;tfoot&gt;
  &lt;tr&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;b&gt;Report parameters&lt;/b&gt;&lt;/td&gt;
    &lt;td&gt;&lt;b&gt;Parameter values&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;state&lt;/td&gt;
    &lt;td&gt;{parm.state}&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tfoot&gt;


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 &amp;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.