Display record-specific charts in Analytics
Forest Admin’s dashboard is handy when it comes to monitoring the overall KPIs. But you may find the analytics module useful for a more in-depth examination of a specific company, user or any other items.
“Analytics per record” are only supported in the Smart and Query modes.
- For Query charts, use the character
?to inject the current record the user is currently seeing to your query.
- For API charts, the parameter
record_idis automatically passed in the HTTP body to access the record the user is currently seeing.
A chart added on a record with such parameters will work for all records.
For security reasons, only
SELECTqueries are allowed.
In the following example, we compute the number of transactions per month for the company “Deliveroo”. The
companies.idis an integer here, so there’s no need to quote it.
SELECT DATE_TRUNC('month', transactions.created_at) AS key, SUM(transactions.amount) / 100 AS value
JOIN transactions ON companies.id = transactions.beneficiary_company_id
WHERE companies.id = ?
GROUP BY key;