Merlin – Do a bit of magic in reports – part III

Those of you who have checked our new post series about “Merlin report templates” know by now…

Now let’s do some magic with the reports.


What if you want to list overdue tasks along with the next activities, in “Next Due Activities” report?

The ‘Next Due Activities’ report lists not yet completed activities ending today or within the time period defined in the report’s options. This is done by a ‘select’ in the Report.xslt file:

<xsl:for-each select="(//Activity | //Project) [not(Activity) and xs:dateTime(expectedEndDate) &lt;= xs:dateTime($maxDate) and xs:dateTime(expectedEndDate) &gt;= $now and actualCompletion &lt; 1.0]">

If you would like to list over due tasks as well you would need to modify the select not to check if the expected End Date is greater than the current time point… thus:

<xsl:for-each select="(//Activity | //Project) [./Assignment/title=$showResource and xs:dateTime(expectedEndDate) &lt;= xs:dateTime($maxDate) and actualCompletion &lt; 1.0]">

Note: In this report template you will find 2 selects. Once for reporting for all resources, and a second time for reporting tasks of the selected resource. Make sure you change them both.

Also if preparing this report  for someone else which may use it in German, remember to change the selects in the Report.xslt underneath the German.lproj as well.

Surely you can create an option for your report, so you as user could decide whether or not to include overdue activities in the outputted report. This is fine, you know by now how to do this, just put your special selects in your own conditional if blocks. For example:

<xsl:if test="$withOverdues = 1">
       <xsl:for-each select="(//Activity | //Project) [not(Activity) and xs:dateTime(expectedEndDate) &lt;= xs:dateTime($maxDate) and actualCompletion &lt; 1.0]">

Downloadables: You will find a copy of this report template in a related thread in the Merlin user forum as an attachment for you to download


UPDATE [Sept 8, 2011]: The standard template was not outputing long activities having an expected end past beyond the duration defined in the options. To solve this the select row should also contain a check for expectedStartDate. So when checking the tasks without overdues the select row should be changed thus:

<xsl:for-each select="(//Activity | //Project) [not(Activity) and ((xs:dateTime(expectedStartDate) &gt;=$now and xs:dateTime(expectedEndDate) &lt;= xs:dateTime($maxDate)) or  (xs:dateTime(expectedStartDate) &gt;= $now and xs:dateTime(expectedStartDate) &lt;= xs:dateTime($maxDate))) and actualCompletion &lt; 1.0 ]">

And when testing for the overdues just select…

<xsl:for-each select="(//Activity | //Project) [not(Activity) and xs:dateTime(expectedStartDate) &lt;= xs:dateTime($maxDate) and actualCompletion &lt; 1.0 ]">

Downloadables: You may download this new version of the template from here having all selects correctly when reporting for all resources, just for a specified, in German or in English.