There are lots of little things you can do that can improve calculation performance.
Distinct counting values is one of the slowest aggregation types in almost all data sources. Use the COUNTD aggregation sparingly.
Using parameters with a wide scope of impact (for example, in a custom SQL statement) can affect cache performance.
Filtering on complex calculations can potentially cause indexes to be missed in the underlying data.
Script functions like RAWSQL and SCRIPT_* for integrating with external services can be slow, particularly if there are lots of values that need to be passed back and forth from the DBMS/R server.
Use NOW only if you need the time stamp level of detail. Use TODAY for date level calculations.
Remember that all basic calculations are passed through to the underlying data—even literal calculations like label strings. If you need to create labels (for example, for column headers) and your data is very large, create a simple text/Excel file data source with just one record to hold them so they don’t add overhead on the big data source.