Calculations Best Practices

Calculations in reports

If a calculation is used in a report, then any relationships that are followed in the calculations are internally converted to report nodes in the report. Similarly, any aggregates that appear in the calculation also get turned into aggregates in the report. This also applies to the use of Calculated Fields. These can be viewed in the Report Diagnostics tool.

Aggregates

Aggregates, such as sum, max, min and count, in calculations can cause a very large number of records to be accessed (and secured) in the process of generating a report. If aggregation is required, then be mindful of the number of records that may be accessed and of the security rules that will apply to those records.

Calculations that follow relationships

Every calculation relationship node must be secured in the same way as for following a relationship normally. 

If you follow the same relationship more than once, then in some very limited scenarios the calculation engine is able to share the same node in the generated report, which is more efficient. For this to be possible, the same relationship path needs to be followed from the root, and there cannot be any where clause.

(warning) If you need to access something more than once, then assign it to a variable using "let". This makes it much more likely that the calculation engine will be able to generate an efficient report.

Date functions

(warning) As with the analyser, any calculations that refer to the current time will cause the report result to not be cached. Therefore use the getdate function in preference to the getdatetime function.